Index: third_party/WebKit/Source/core/editing/RelocatablePosition.cpp |
diff --git a/third_party/WebKit/Source/core/editing/RelocatablePosition.cpp b/third_party/WebKit/Source/core/editing/RelocatablePosition.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1751cf3d6afaace89552f024284ef5bcd965f728 |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/editing/RelocatablePosition.cpp |
@@ -0,0 +1,29 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "core/editing/RelocatablePosition.h" |
+ |
+namespace blink { |
+ |
+RelocatablePosition::RelocatablePosition(const Position& position) |
+ : m_range(position.isNotNull() ? Range::create(*position.document(), position, position) : nullptr) |
+{ |
+} |
+ |
+RelocatablePosition::~RelocatablePosition() |
+{ |
+ if (!m_range) |
+ return; |
+ m_range->dispose(); |
+} |
+ |
+Position RelocatablePosition::position() const |
+{ |
+ if (!m_range) |
+ return Position(); |
+ DCHECK(m_range->collapsed()); |
+ return m_range->startPosition(); |
+} |
+ |
+} // namespace blink |