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

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

Issue 2022863002: [InputEvent] Introduce |StaticRange| and use in |InputEvent::getRanges()| (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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
(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
20 class CORE_EXPORT StaticRange final : public GarbageCollected<StaticRange>, publ ic ScriptWrappable {
21 DEFINE_WRAPPERTYPEINFO();
22
23 public:
24 static StaticRange* create(Document& document)
25 {
26 return new StaticRange(document);
27 }
28 static StaticRange* create(Document& document, Node* startContainer, int sta rtOffset, Node* endContainer, int endOffset)
29 {
30 return new StaticRange(document, startContainer, startOffset, endContain er, endOffset);
31 }
32
33 Node* startContainer() const { return m_startContainer.get(); }
34 void setStartContainer(Node* startContainer) { m_startContainer = startConta iner; }
35
36 int startOffset() const { return m_startOffset; }
37 void setStartOffset(int startOffset) { m_startOffset = startOffset; }
38
39 Node* endContainer() const { return m_endContainer.get(); }
40 void setEndContainer(Node* endContainer) { m_endContainer = endContainer; }
41
42 int endOffset() const { return m_endOffset; }
43 void setEndOffset(int endOffset) { m_endOffset = endOffset; }
44
45 bool collapsed() const { return m_startContainer == m_endContainer && m_star tOffset == m_endOffset; }
46
47 void setStart(Node* container, int offset);
48 void setEnd(Node* container, int offset);
49
50 Range* toRange(ExceptionState&) const;
51
52 DECLARE_TRACE();
53
54 private:
55 explicit StaticRange(Document&);
56 StaticRange(Document&, Node* startContainer, int startOffset, Node* endConta iner, int endOffset);
57
58 Member<Document> m_ownerDocument; // Required by |toRange()|.
59 Member<Node> m_startContainer;
60 int m_startOffset;
61 Member<Node> m_endContainer;
62 int m_endOffset;
63 };
64
65 using StaticRangeVector = HeapVector<Member<StaticRange>>;
66
67 } // namespace blink
68
69 #endif // StaticRange_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/core.gypi ('k') | third_party/WebKit/Source/core/dom/StaticRange.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698