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

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

Issue 2701413003: Range: node offsets should be unsigned. (Closed)
Patch Set: Resolve std::numeric_limits<int>::max() leftover Created 3 years, 10 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
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no)
4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no)
5 * (C) 2001 Peter Kelly (pmk@post.com) 5 * (C) 2001 Peter Kelly (pmk@post.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
7 * reserved. 7 * reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 class Text; 49 class Text;
50 50
51 class CORE_EXPORT Range final : public GarbageCollected<Range>, 51 class CORE_EXPORT Range final : public GarbageCollected<Range>,
52 public ScriptWrappable { 52 public ScriptWrappable {
53 DEFINE_WRAPPERTYPEINFO(); 53 DEFINE_WRAPPERTYPEINFO();
54 54
55 public: 55 public:
56 static Range* create(Document&); 56 static Range* create(Document&);
57 static Range* create(Document&, 57 static Range* create(Document&,
58 Node* startContainer, 58 Node* startContainer,
59 int startOffset, 59 unsigned startOffset,
60 Node* endContainer, 60 Node* endContainer,
61 int endOffset); 61 unsigned endOffset);
62 static Range* create(Document&, const Position&, const Position&); 62 static Range* create(Document&, const Position&, const Position&);
63 static Range* createAdjustedToTreeScope(const TreeScope&, const Position&); 63 static Range* createAdjustedToTreeScope(const TreeScope&, const Position&);
64 64
65 void dispose(); 65 void dispose();
66 66
67 Document& ownerDocument() const { 67 Document& ownerDocument() const {
68 DCHECK(m_ownerDocument); 68 DCHECK(m_ownerDocument);
69 return *m_ownerDocument.get(); 69 return *m_ownerDocument.get();
70 } 70 }
71 Node* startContainer() const { return m_start.container(); } 71 Node* startContainer() const { return m_start.container(); }
72 int startOffset() const { return m_start.offset(); } 72 unsigned startOffset() const { return m_start.offset(); }
73 Node* endContainer() const { return m_end.container(); } 73 Node* endContainer() const { return m_end.container(); }
74 int endOffset() const { return m_end.offset(); } 74 unsigned endOffset() const { return m_end.offset(); }
75 75
76 bool collapsed() const { return m_start == m_end; } 76 bool collapsed() const { return m_start == m_end; }
77 bool isConnected() const; 77 bool isConnected() const;
78 78
79 Node* commonAncestorContainer() const; 79 Node* commonAncestorContainer() const;
80 static Node* commonAncestorContainer(const Node* containerA, 80 static Node* commonAncestorContainer(const Node* containerA,
81 const Node* containerB); 81 const Node* containerB);
82 void setStart(Node* container, 82 void setStart(Node* container,
83 int offset, 83 unsigned offset,
84 ExceptionState& = ASSERT_NO_EXCEPTION); 84 ExceptionState& = ASSERT_NO_EXCEPTION);
85 void setEnd(Node* container, 85 void setEnd(Node* container,
86 int offset, 86 unsigned offset,
87 ExceptionState& = ASSERT_NO_EXCEPTION); 87 ExceptionState& = ASSERT_NO_EXCEPTION);
88 void collapse(bool toStart); 88 void collapse(bool toStart);
89 bool isNodeFullyContained(Node&) const; 89 bool isNodeFullyContained(Node&) const;
90 bool isPointInRange(Node* refNode, int offset, ExceptionState&) const; 90 bool isPointInRange(Node* refNode, unsigned offset, ExceptionState&) const;
91 short comparePoint(Node* refNode, int offset, ExceptionState&) const; 91 short comparePoint(Node* refNode, unsigned offset, ExceptionState&) const;
92 enum CompareResults { 92 enum CompareResults {
93 NODE_BEFORE, 93 NODE_BEFORE,
94 NODE_AFTER, 94 NODE_AFTER,
95 NODE_BEFORE_AND_AFTER, 95 NODE_BEFORE_AND_AFTER,
96 NODE_INSIDE 96 NODE_INSIDE
97 }; 97 };
98 enum CompareHow { kStartToStart, kStartToEnd, kEndToEnd, kEndToStart }; 98 enum CompareHow { kStartToStart, kStartToEnd, kEndToEnd, kEndToStart };
99 short compareBoundaryPoints(unsigned how, 99 short compareBoundaryPoints(unsigned how,
100 const Range* sourceRange, 100 const Range* sourceRange,
101 ExceptionState&) const; 101 ExceptionState&) const;
102 static short compareBoundaryPoints(Node* containerA, 102 static short compareBoundaryPoints(Node* containerA,
103 int offsetA, 103 unsigned offsetA,
104 Node* containerB, 104 Node* containerB,
105 int offsetB, 105 unsigned offsetB,
106 ExceptionState&); 106 ExceptionState&);
107 static short compareBoundaryPoints(const RangeBoundaryPoint& boundaryA, 107 static short compareBoundaryPoints(const RangeBoundaryPoint& boundaryA,
108 const RangeBoundaryPoint& boundaryB, 108 const RangeBoundaryPoint& boundaryB,
109 ExceptionState&); 109 ExceptionState&);
110 bool boundaryPointsValid() const; 110 bool boundaryPointsValid() const;
111 bool intersectsNode(Node* refNode, ExceptionState&); 111 bool intersectsNode(Node* refNode, ExceptionState&);
112 void deleteContents(ExceptionState&); 112 void deleteContents(ExceptionState&);
113 DocumentFragment* extractContents(ExceptionState&); 113 DocumentFragment* extractContents(ExceptionState&);
114 DocumentFragment* cloneContents(ExceptionState&); 114 DocumentFragment* cloneContents(ExceptionState&);
115 void insertNode(Node*, ExceptionState&); 115 void insertNode(Node*, ExceptionState&);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 void updateOwnerDocumentIfNeeded(); 159 void updateOwnerDocumentIfNeeded();
160 160
161 // Expand range to a unit (word or sentence or block or document) boundary. 161 // Expand range to a unit (word or sentence or block or document) boundary.
162 // Please refer to https://bugs.webkit.org/show_bug.cgi?id=27632 comment #5 162 // Please refer to https://bugs.webkit.org/show_bug.cgi?id=27632 comment #5
163 // for details. 163 // for details.
164 void expand(const String&, ExceptionState&); 164 void expand(const String&, ExceptionState&);
165 165
166 ClientRectList* getClientRects() const; 166 ClientRectList* getClientRects() const;
167 ClientRect* getBoundingClientRect() const; 167 ClientRect* getBoundingClientRect() const;
168 168
169 static Node* checkNodeWOffset(Node*, int offset, ExceptionState&); 169 static Node* checkNodeWOffset(Node*, unsigned offset, ExceptionState&);
170 170
171 DECLARE_TRACE(); 171 DECLARE_TRACE();
172 172
173 private: 173 private:
174 explicit Range(Document&); 174 explicit Range(Document&);
175 Range(Document&, 175 Range(Document&,
176 Node* startContainer, 176 Node* startContainer,
177 int startOffset, 177 unsigned startOffset,
178 Node* endContainer, 178 Node* endContainer,
179 int endOffset); 179 unsigned endOffset);
180 180
181 void setDocument(Document&); 181 void setDocument(Document&);
182 182
183 void checkNodeBA(Node*, ExceptionState&) const; 183 void checkNodeBA(Node*, ExceptionState&) const;
184 void checkExtractPrecondition(ExceptionState&); 184 void checkExtractPrecondition(ExceptionState&);
185 bool hasSameRoot(const Node&) const; 185 bool hasSameRoot(const Node&) const;
186 186
187 enum ActionType { DELETE_CONTENTS, EXTRACT_CONTENTS, CLONE_CONTENTS }; 187 enum ActionType { DELETE_CONTENTS, EXTRACT_CONTENTS, CLONE_CONTENTS };
188 DocumentFragment* processContents(ActionType, ExceptionState&); 188 DocumentFragment* processContents(ActionType, ExceptionState&);
189 static Node* processContentsBetweenOffsets(ActionType, 189 static Node* processContentsBetweenOffsets(ActionType,
(...skipping 30 matching lines...) Expand all
220 using RangeVector = HeapVector<Member<Range>>; 220 using RangeVector = HeapVector<Member<Range>>;
221 221
222 } // namespace blink 222 } // namespace blink
223 223
224 #ifndef NDEBUG 224 #ifndef NDEBUG
225 // Outside the WebCore namespace for ease of invocation from gdb. 225 // Outside the WebCore namespace for ease of invocation from gdb.
226 void showTree(const blink::Range*); 226 void showTree(const blink::Range*);
227 #endif 227 #endif
228 228
229 #endif // Range_h 229 #endif // Range_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698