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

Side by Side Diff: third_party/WebKit/Source/core/editing/PositionIterator.h

Issue 2725803002: Introduce PositionIteratorTest in webkit_unit_tests (Closed)
Patch Set: 2017-03-01T15:38:19 Add EXPECT_EQ() just after ctor by yoichio@'s comment Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef PositionIterator_h 26 #ifndef PositionIterator_h
27 #define PositionIterator_h 27 #define PositionIterator_h
28 28
29 #include "core/CoreExport.h"
29 #include "core/dom/Node.h" 30 #include "core/dom/Node.h"
30 #include "core/editing/EditingStrategy.h" 31 #include "core/editing/EditingStrategy.h"
31 #include "core/editing/EditingUtilities.h" 32 #include "core/editing/EditingUtilities.h"
32 #include "core/html/HTMLHtmlElement.h" 33 #include "core/html/HTMLHtmlElement.h"
33 34
34 namespace blink { 35 namespace blink {
35 36
36 // A Position iterator with nearly constant-time 37 // A Position iterator with nearly constant-time
37 // increment, decrement, and several predicates on the Position it is at. 38 // increment, decrement, and several predicates on the Position it is at.
38 // Conversion from Position is O(n) in the depth. 39 // Conversion from Position is O(n) in the depth.
39 // Conversion to Position is O(1). 40 // Conversion to Position is O(1).
40 // PositionIteratorAlgorithm must be used without DOM tree change. 41 // PositionIteratorAlgorithm must be used without DOM tree change.
41 template <typename Strategy> 42 template <typename Strategy>
42 class PositionIteratorAlgorithm { 43 class CORE_TEMPLATE_CLASS_EXPORT PositionIteratorAlgorithm {
43 STACK_ALLOCATED(); 44 STACK_ALLOCATED();
44 45
45 public: 46 public:
46 explicit PositionIteratorAlgorithm(const PositionTemplate<Strategy>&); 47 explicit PositionIteratorAlgorithm(const PositionTemplate<Strategy>&);
47 PositionIteratorAlgorithm(); 48 PositionIteratorAlgorithm();
48 49
49 // Since |deprecatedComputePosition()| is slow, new code should use 50 // Since |deprecatedComputePosition()| is slow, new code should use
50 // |computePosition()| instead. 51 // |computePosition()| instead.
51 PositionTemplate<Strategy> deprecatedComputePosition() const; 52 PositionTemplate<Strategy> deprecatedComputePosition() const;
52 PositionTemplate<Strategy> computePosition() const; 53 PositionTemplate<Strategy> computePosition() const;
(...skipping 30 matching lines...) Expand all
83 Member<Node> m_nodeAfterPositionInAnchor; 84 Member<Node> m_nodeAfterPositionInAnchor;
84 int m_offsetInAnchor; 85 int m_offsetInAnchor;
85 size_t m_depthToAnchorNode; 86 size_t m_depthToAnchorNode;
86 // If |m_nodeAfterPositionInAnchor| is not null, 87 // If |m_nodeAfterPositionInAnchor| is not null,
87 // m_offsetsInAnchorNode[m_depthToAnchorNode] == 88 // m_offsetsInAnchorNode[m_depthToAnchorNode] ==
88 // Strategy::index(m_nodeAfterPositionInAnchor). 89 // Strategy::index(m_nodeAfterPositionInAnchor).
89 Vector<int> m_offsetsInAnchorNode; 90 Vector<int> m_offsetsInAnchorNode;
90 uint64_t m_domTreeVersion; 91 uint64_t m_domTreeVersion;
91 }; 92 };
92 93
93 extern template class PositionIteratorAlgorithm<EditingStrategy>; 94 extern template class CORE_EXTERN_TEMPLATE_EXPORT
94 extern template class PositionIteratorAlgorithm<EditingInFlatTreeStrategy>; 95 PositionIteratorAlgorithm<EditingStrategy>;
96 extern template class CORE_EXTERN_TEMPLATE_EXPORT
97 PositionIteratorAlgorithm<EditingInFlatTreeStrategy>;
95 98
96 using PositionIterator = PositionIteratorAlgorithm<EditingStrategy>; 99 using PositionIterator = PositionIteratorAlgorithm<EditingStrategy>;
97 using PositionIteratorInFlatTree = 100 using PositionIteratorInFlatTree =
98 PositionIteratorAlgorithm<EditingInFlatTreeStrategy>; 101 PositionIteratorAlgorithm<EditingInFlatTreeStrategy>;
99 102
100 } // namespace blink 103 } // namespace blink
101 104
102 #endif // PositionIterator_h 105 #endif // PositionIterator_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/BUILD.gn ('k') | third_party/WebKit/Source/core/editing/PositionIterator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698