// Copyright 2015 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_EPHEMERAL_RANGE_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_EPHEMERAL_RANGE_H_ #include "base/dcheck_is_on.h" #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/editing/position.h" namespace blink { class Document; class AbstractRange; class Range; // We should restrict access to the unwanted version of |TraversalRange::end()| // function. template <class Iterator> class TraversalRangeNodes : private TraversalRange<Iterator> { … }; // This class acts like |TraversalNextIterator| but in addition // it allows to set current position and checks |current_| pointer before // dereferencing. template <class TraversalNext> class CheckedTraversalNextIterator : public TraversalIteratorBase<TraversalNext> { … }; // Unlike |Range| objects, |EphemeralRangeTemplate| objects aren't relocated. // You should not use |EphemeralRangeTemplate| objects after DOM modification. // // EphemeralRangeTemplate is supposed to use returning or passing start and end // position. // // Example usage: // Range* range = produceRange(); // consumeRange(range); // ... no DOM modification ... // consumeRange2(range); // // Above code should be: // EphemeralRangeTemplate range = produceRange(); // consumeRange(range); // ... no DOM modification ... // consumeRange2(range); // // Because of |Range| objects consume heap memory and inserted into |Range| // object list in |Document| for relocation. These operations are redundant // if |Range| objects doesn't live after DOM mutation. // template <typename Strategy> class EphemeralRangeTemplate final { … }; extern template class CORE_EXTERN_TEMPLATE_EXPORT EphemeralRangeTemplate<EditingStrategy>; EphemeralRange; extern template class CORE_EXTERN_TEMPLATE_EXPORT EphemeralRangeTemplate<EditingInFlatTreeStrategy>; EphemeralRangeInFlatTree; // Returns a newly created |Range| object from |range| or |nullptr| if // |range.isNull()| returns true. CORE_EXPORT Range* CreateRange(const EphemeralRange& /* range */); CORE_EXPORT std::ostream& operator<<(std::ostream&, const EphemeralRange&); CORE_EXPORT std::ostream& operator<<(std::ostream&, const EphemeralRangeInFlatTree&); CORE_EXPORT EphemeralRangeInFlatTree ToEphemeralRangeInFlatTree(const EphemeralRange&); } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_EPHEMERAL_RANGE_H_