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

Unified Diff: third_party/WebKit/Source/core/editing/Position.cpp

Issue 2229703002: Improve canBeAnchorNode() for PositionInFlatTree constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-08-09T13:48:05 Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/Position.cpp
diff --git a/third_party/WebKit/Source/core/editing/Position.cpp b/third_party/WebKit/Source/core/editing/Position.cpp
index 01f0364a006e652f08bdf32c1affcd23bf5451aa..f343ff8c18335bef246b6139249fc1e44f5d87ac 100644
--- a/third_party/WebKit/Source/core/editing/Position.cpp
+++ b/third_party/WebKit/Source/core/editing/Position.cpp
@@ -35,10 +35,20 @@
namespace blink {
#if DCHECK_IS_ON()
-static bool canBeAnchorNode(Node* node)
+template <typename Strategy>
+static bool canBeAnchorNode(Node*);
+
+template <>
+bool canBeAnchorNode<EditingStrategy>(Node* node)
{
return !node || !node->isPseudoElement();
}
+
+template <>
+bool canBeAnchorNode<EditingInFlatTreeStrategy>(Node* node)
+{
+ return canBeAnchorNode<EditingStrategy>(node) && node->canParticipateInFlatTree();
+}
#endif
template <typename Strategy>
@@ -89,7 +99,7 @@ PositionTemplate<Strategy>::PositionTemplate(Node* anchorNode, PositionAnchorTyp
return;
}
#if DCHECK_IS_ON()
- DCHECK(canBeAnchorNode(m_anchorNode.get()));
+ DCHECK(canBeAnchorNode<Strategy>(m_anchorNode.get())) << m_anchorNode;
#endif
DCHECK_NE(m_anchorType, PositionAnchorType::OffsetInAnchor);
}
@@ -105,7 +115,7 @@ PositionTemplate<Strategy>::PositionTemplate(Node* anchorNode, int offset)
else
DCHECK_EQ(offset, 0);
#if DCHECK_IS_ON()
- DCHECK(canBeAnchorNode(m_anchorNode.get()));
+ DCHECK(canBeAnchorNode<Strategy>(m_anchorNode.get())) << m_anchorNode;
#endif
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698