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

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

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 #include "core/dom/StaticRange.h"
8
9 #include "bindings/core/v8/ExceptionState.h"
10 #include "bindings/core/v8/ScriptState.h"
11 #include "core/dom/Range.h"
12 #include "core/frame/LocalDOMWindow.h"
13
14 namespace blink {
15
16 StaticRange::StaticRange(Document& document)
17 : m_ownerDocument(document)
18 , m_startContainer(nullptr)
19 , m_startOffset(0)
20 , m_endContainer(nullptr)
21 , m_endOffset(0)
22 {
23 }
24
25 StaticRange::StaticRange(Document& document, Node* startContainer, int startOffs et, Node* endContainer, int endOffset)
26 : m_ownerDocument(document)
27 , m_startContainer(startContainer)
28 , m_startOffset(startOffset)
29 , m_endContainer(endContainer)
30 , m_endOffset(endOffset)
31 {
32 }
33
34 void StaticRange::setStart(Node* container, int offset)
35 {
36 m_startContainer = container;
37 m_startOffset = offset;
38 }
39
40 void StaticRange::setEnd(Node* container, int offset)
41 {
42 m_endContainer = container;
43 m_endOffset = offset;
44 }
45
46 Range* StaticRange::toRange(ExceptionState& exceptionState) const
47 {
48 Range* range = Range::create(*m_ownerDocument.get());
49 // Do the offset checking.
50 range->setStart(m_startContainer, m_startOffset, exceptionState);
51 range->setEnd(m_endContainer, m_endOffset, exceptionState);
52 return range;
53 }
54
55 DEFINE_TRACE(StaticRange)
56 {
57 visitor->trace(m_ownerDocument);
58 visitor->trace(m_startContainer);
59 visitor->trace(m_endContainer);
60 }
61
62 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/StaticRange.h ('k') | third_party/WebKit/Source/core/dom/StaticRange.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698