Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 // https://discourse.wicg.io/t/proposal-staticrange-to-be-used-instead-of-range- for-new-apis/1472 | |
| 6 | |
| 7 #ifndef StaticRange_h | |
| 8 #define StaticRange_h | |
| 9 | |
| 10 #include "bindings/core/v8/ScriptWrappable.h" | |
| 11 #include "core/CoreExport.h" | |
| 12 #include "platform/heap/Handle.h" | |
| 13 | |
| 14 namespace blink { | |
| 15 | |
| 16 class Document; | |
| 17 class ExceptionState; | |
| 18 class Range; | |
| 19 class ScriptState; | |
| 20 | |
| 21 class CORE_EXPORT StaticRange final : public GarbageCollected<StaticRange>, publ ic ScriptWrappable { | |
| 22 DEFINE_WRAPPERTYPEINFO(); | |
| 23 | |
| 24 public: | |
| 25 static StaticRange* create() | |
| 26 { | |
| 27 return new StaticRange(); | |
| 28 } | |
| 29 static StaticRange* create(Node* startContainer, int startOffset, Node* endC ontainer, int endOffset) | |
| 30 { | |
| 31 return new StaticRange(startContainer, startOffset, endContainer, endOff set); | |
| 32 } | |
| 33 | |
| 34 Node* startContainer() const { return m_startContainer.get(); } | |
| 35 void setStartContainer(Node* startContainer) { m_startContainer = startConta iner; } | |
| 36 | |
| 37 int startOffset() const { return m_startOffset; } | |
| 38 void setStartOffset(int startOffset) { m_startOffset = startOffset; } | |
| 39 | |
| 40 Node* endContainer() const { return m_endContainer.get(); } | |
| 41 void setEndContainer(Node* endContainer) { m_endContainer = endContainer; } | |
| 42 | |
| 43 int endOffset() const { return m_endOffset; } | |
| 44 void setEndOffset(int endOffset) { m_endOffset = endOffset; } | |
| 45 | |
| 46 bool collapsed() const { return m_startContainer == m_endContainer && m_star tOffset == m_endOffset; } | |
| 47 | |
| 48 void setStart(Node* container, int offset); | |
| 49 void setEnd(Node* container, int offset); | |
| 50 | |
| 51 Range* toRange(ScriptState*, ExceptionState&) const; | |
| 52 | |
| 53 DECLARE_TRACE(); | |
| 54 | |
| 55 private: | |
| 56 friend class StaticRangeTest; | |
| 57 explicit StaticRange(); | |
|
dtapuska
2016/06/02 15:26:29
why explicit on non param constructor? doesn't mak
chongz
2016/06/06 19:43:43
Added |Document&|.
| |
| 58 StaticRange(Node* startContainer, int startOffset, Node* endContainer, int e ndOffset); | |
| 59 | |
| 60 Range* toRangeImpl(Document&, ExceptionState&) const; | |
| 61 | |
| 62 Member<Node> m_startContainer; | |
|
dtapuska
2016/06/02 15:26:29
I guess my hope was that in the class structure
R
chongz
2016/06/06 19:43:43
garykac@ mentioned that there are concerns about c
| |
| 63 int m_startOffset; | |
| 64 Member<Node> m_endContainer; | |
| 65 int m_endOffset; | |
| 66 }; | |
| 67 | |
| 68 using StaticRangeVector = HeapVector<Member<StaticRange>>; | |
| 69 | |
| 70 } // namespace blink | |
| 71 | |
| 72 #endif // StaticRange_h | |
| OLD | NEW |