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

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

Issue 2731393004: Use EphemeralRange to construct StaticRange (Closed)
Patch Set: 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 // 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 return new StaticRange(range.document(),
yosin_UTC9 2017/03/08 07:35:51 Let's add |DCHECK(!range.isNull());| since creatin
chongz 2017/03/08 18:31:09 Done.
44 range.startPosition().computeContainerNode(),
45 range.startPosition().computeOffsetInContainerNode(),
46 range.endPosition().computeContainerNode(),
47 range.endPosition().computeOffsetInContainerNode());
48 }
41 49
42 Node* startContainer() const { return m_startContainer.get(); } 50 Node* startContainer() const { return m_startContainer.get(); }
43 void setStartContainer(Node* startContainer) { 51 void setStartContainer(Node* startContainer) {
44 m_startContainer = startContainer; 52 m_startContainer = startContainer;
45 } 53 }
46 54
47 int startOffset() const { return m_startOffset; } 55 int startOffset() const { return m_startOffset; }
48 void setStartOffset(int startOffset) { m_startOffset = startOffset; } 56 void setStartOffset(int startOffset) { m_startOffset = startOffset; }
49 57
50 Node* endContainer() const { return m_endContainer.get(); } 58 Node* endContainer() const { return m_endContainer.get(); }
(...skipping 26 matching lines...) Expand all
77 int m_startOffset; 85 int m_startOffset;
78 Member<Node> m_endContainer; 86 Member<Node> m_endContainer;
79 int m_endOffset; 87 int m_endOffset;
80 }; 88 };
81 89
82 using StaticRangeVector = HeapVector<Member<StaticRange>>; 90 using StaticRangeVector = HeapVector<Member<StaticRange>>;
83 91
84 } // namespace blink 92 } // namespace blink
85 93
86 #endif // StaticRange_h 94 #endif // StaticRange_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698