1 // Copyright 2016 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "third_party/blink/renderer/core/editing/relocatable_position.h" 6 #include "third_party/blink/renderer/platform/heap/heap.h" 7 8 namespace blink { 9 RelocatablePosition(const Position & position)10RelocatablePosition::RelocatablePosition(const Position& position) 11 : range_(position.IsNotNull() 12 ? MakeGarbageCollected<Range>(*position.GetDocument(), 13 position, 14 position) 15 : nullptr) {} 16 ~RelocatablePosition()17RelocatablePosition::~RelocatablePosition() { 18 if (!range_) 19 return; 20 range_->Dispose(); 21 } 22 GetPosition() const23Position RelocatablePosition::GetPosition() const { 24 if (!range_) 25 return Position(); 26 DCHECK(range_->collapsed()); 27 return range_->StartPosition(); 28 } 29 30 } // namespace blink 31