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

Unified 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: Introduce |StaticRange| and add tests Created 4 years, 7 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.h
diff --git a/third_party/WebKit/Source/core/dom/StaticRange.h b/third_party/WebKit/Source/core/dom/StaticRange.h
new file mode 100644
index 0000000000000000000000000000000000000000..023e37fef49be179d6f03e0944eee9abdad03407
--- /dev/null
+++ b/third_party/WebKit/Source/core/dom/StaticRange.h
@@ -0,0 +1,72 @@
+// 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
+
+#ifndef StaticRange_h
+#define StaticRange_h
+
+#include "bindings/core/v8/ScriptWrappable.h"
+#include "core/CoreExport.h"
+#include "platform/heap/Handle.h"
+
+namespace blink {
+
+class Document;
+class ExceptionState;
+class Range;
+class ScriptState;
+
+class CORE_EXPORT StaticRange final : public GarbageCollected<StaticRange>, public ScriptWrappable {
+ DEFINE_WRAPPERTYPEINFO();
+
+public:
+ static StaticRange* create()
+ {
+ return new StaticRange();
+ }
+ static StaticRange* create(Node* startContainer, int startOffset, Node* endContainer, int endOffset)
+ {
+ return new StaticRange(startContainer, startOffset, endContainer, endOffset);
+ }
+
+ Node* startContainer() const { return m_startContainer.get(); }
+ void setStartContainer(Node* startContainer) { m_startContainer = startContainer; }
+
+ int startOffset() const { return m_startOffset; }
+ void setStartOffset(int startOffset) { m_startOffset = startOffset; }
+
+ Node* endContainer() const { return m_endContainer.get(); }
+ void setEndContainer(Node* endContainer) { m_endContainer = endContainer; }
+
+ int endOffset() const { return m_endOffset; }
+ void setEndOffset(int endOffset) { m_endOffset = endOffset; }
+
+ bool collapsed() const { return m_startContainer == m_endContainer && m_startOffset == m_endOffset; }
+
+ void setStart(Node* container, int offset);
+ void setEnd(Node* container, int offset);
+
+ Range* toRange(ScriptState*, ExceptionState&) const;
+
+ DECLARE_TRACE();
+
+private:
+ friend class StaticRangeTest;
+ 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&|.
+ StaticRange(Node* startContainer, int startOffset, Node* endContainer, int endOffset);
+
+ Range* toRangeImpl(Document&, ExceptionState&) const;
+
+ 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
+ int m_startOffset;
+ Member<Node> m_endContainer;
+ int m_endOffset;
+};
+
+using StaticRangeVector = HeapVector<Member<StaticRange>>;
+
+} // namespace blink
+
+#endif // StaticRange_h

Powered by Google App Engine
This is Rietveld 408576698