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

Side by Side Diff: third_party/WebKit/Source/core/dom/StaticRange.h

Issue 2731393004: Use EphemeralRange to construct StaticRange (Closed)
Patch Set: yosin's review: Fix nits 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/EditingUtilities.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // https://discourse.wicg.io/t/proposal-staticrange-to-be-used-instead-of-range- for-new-apis/1472 5 // https://discourse.wicg.io/t/proposal-staticrange-to-be-used-instead-of-range- for-new-apis/1472
6 6
7 #ifndef StaticRange_h 7 #ifndef StaticRange_h
8 #define StaticRange_h 8 #define StaticRange_h
9 9
10 #include "bindings/core/v8/ScriptWrappable.h" 10 #include "bindings/core/v8/ScriptWrappable.h"
11 #include "core/CoreExport.h" 11 #include "core/CoreExport.h"
12 #include "core/dom/Range.h" 12 #include "core/dom/Range.h"
13 #include "core/editing/EphemeralRange.h"
13 #include "platform/heap/Handle.h" 14 #include "platform/heap/Handle.h"
14 15
15 namespace blink { 16 namespace blink {
16 17
17 class Document; 18 class Document;
18 class ExceptionState; 19 class ExceptionState;
19 20
20 class CORE_EXPORT StaticRange final : public GarbageCollected<StaticRange>, 21 class CORE_EXPORT StaticRange final : public GarbageCollected<StaticRange>,
21 public ScriptWrappable { 22 public ScriptWrappable {
22 DEFINE_WRAPPERTYPEINFO(); 23 DEFINE_WRAPPERTYPEINFO();
23 24
24 public: 25 public:
25 static StaticRange* create(Document& document) { 26 static StaticRange* create(Document& document) {
26 return new StaticRange(document); 27 return new StaticRange(document);
27 } 28 }
28 static StaticRange* create(Document& document, 29 static StaticRange* create(Document& document,
29 Node* startContainer, 30 Node* startContainer,
30 int startOffset, 31 int startOffset,
31 Node* endContainer, 32 Node* endContainer,
32 int endOffset) { 33 int endOffset) {
33 return new StaticRange(document, startContainer, startOffset, endContainer, 34 return new StaticRange(document, startContainer, startOffset, endContainer,
34 endOffset); 35 endOffset);
35 } 36 }
36 static StaticRange* create(const Range* range) { 37 static StaticRange* create(const Range* range) {
37 return new StaticRange(range->ownerDocument(), range->startContainer(), 38 return new StaticRange(range->ownerDocument(), range->startContainer(),
38 range->startOffset(), range->endContainer(), 39 range->startOffset(), range->endContainer(),
39 range->endOffset()); 40 range->endOffset());
40 } 41 }
42 static StaticRange* create(const EphemeralRange& range) {
43 DCHECK(!range.isNull());
44 return new StaticRange(range.document(),
45 range.startPosition().computeContainerNode(),
46 range.startPosition().computeOffsetInContainerNode(),
47 range.endPosition().computeContainerNode(),
48 range.endPosition().computeOffsetInContainerNode());
49 }
41 50
42 Node* startContainer() const { return m_startContainer.get(); } 51 Node* startContainer() const { return m_startContainer.get(); }
43 void setStartContainer(Node* startContainer) { 52 void setStartContainer(Node* startContainer) {
44 m_startContainer = startContainer; 53 m_startContainer = startContainer;
45 } 54 }
46 55
47 int startOffset() const { return m_startOffset; } 56 int startOffset() const { return m_startOffset; }
48 void setStartOffset(int startOffset) { m_startOffset = startOffset; } 57 void setStartOffset(int startOffset) { m_startOffset = startOffset; }
49 58
50 Node* endContainer() const { return m_endContainer.get(); } 59 Node* endContainer() const { return m_endContainer.get(); }
(...skipping 26 matching lines...) Expand all
77 int m_startOffset; 86 int m_startOffset;
78 Member<Node> m_endContainer; 87 Member<Node> m_endContainer;
79 int m_endOffset; 88 int m_endOffset;
80 }; 89 };
81 90
82 using StaticRangeVector = HeapVector<Member<StaticRange>>; 91 using StaticRangeVector = HeapVector<Member<StaticRange>>;
83 92
84 } // namespace blink 93 } // namespace blink
85 94
86 #endif // StaticRange_h 95 #endif // StaticRange_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/EditingUtilities.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698