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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/StaticRange.cpp
diff --git a/third_party/WebKit/Source/core/dom/StaticRange.cpp b/third_party/WebKit/Source/core/dom/StaticRange.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..86082651cba825c77c47fec3bd983def5b10631e
--- /dev/null
+++ b/third_party/WebKit/Source/core/dom/StaticRange.cpp
@@ -0,0 +1,62 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// https://discourse.wicg.io/t/proposal-staticrange-to-be-used-instead-of-range-for-new-apis/1472
+
+#include "core/dom/StaticRange.h"
+
+#include "bindings/core/v8/ExceptionState.h"
+#include "bindings/core/v8/ScriptState.h"
+#include "core/dom/Range.h"
+#include "core/frame/LocalDOMWindow.h"
+
+namespace blink {
+
+StaticRange::StaticRange(Document& document)
+ : m_ownerDocument(document)
+ , m_startContainer(nullptr)
+ , m_startOffset(0)
+ , m_endContainer(nullptr)
+ , m_endOffset(0)
+{
+}
+
+StaticRange::StaticRange(Document& document, Node* startContainer, int startOffset, Node* endContainer, int endOffset)
+ : m_ownerDocument(document)
+ , m_startContainer(startContainer)
+ , m_startOffset(startOffset)
+ , m_endContainer(endContainer)
+ , m_endOffset(endOffset)
+{
+}
+
+void StaticRange::setStart(Node* container, int offset)
+{
+ m_startContainer = container;
+ m_startOffset = offset;
+}
+
+void StaticRange::setEnd(Node* container, int offset)
+{
+ m_endContainer = container;
+ m_endOffset = offset;
+}
+
+Range* StaticRange::toRange(ExceptionState& exceptionState) const
+{
+ Range* range = Range::create(*m_ownerDocument.get());
+ // Do the offset checking.
+ range->setStart(m_startContainer, m_startOffset, exceptionState);
+ range->setEnd(m_endContainer, m_endOffset, exceptionState);
+ return range;
+}
+
+DEFINE_TRACE(StaticRange)
+{
+ visitor->trace(m_ownerDocument);
+ visitor->trace(m_startContainer);
+ visitor->trace(m_endContainer);
+}
+
+} // namespace blink
« 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