OLD | NEW |
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 reserv
ed. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 12 matching lines...) Expand all Loading... |
23 */ | 23 */ |
24 | 24 |
25 #ifndef Range_h | 25 #ifndef Range_h |
26 #define Range_h | 26 #define Range_h |
27 | 27 |
28 #include "bindings/v8/ExceptionStatePlaceholder.h" | 28 #include "bindings/v8/ExceptionStatePlaceholder.h" |
29 #include "bindings/v8/ScriptWrappable.h" | 29 #include "bindings/v8/ScriptWrappable.h" |
30 #include "core/dom/RangeBoundaryPoint.h" | 30 #include "core/dom/RangeBoundaryPoint.h" |
31 #include "platform/geometry/FloatRect.h" | 31 #include "platform/geometry/FloatRect.h" |
32 #include "platform/geometry/IntRect.h" | 32 #include "platform/geometry/IntRect.h" |
| 33 #include "platform/heap/Handle.h" |
33 #include "wtf/Forward.h" | 34 #include "wtf/Forward.h" |
34 #include "wtf/RefCounted.h" | 35 #include "wtf/RefCounted.h" |
35 #include "wtf/Vector.h" | 36 #include "wtf/Vector.h" |
36 | 37 |
37 namespace WebCore { | 38 namespace WebCore { |
38 | 39 |
39 class ClientRect; | 40 class ClientRect; |
40 class ClientRectList; | 41 class ClientRectList; |
41 class ContainerNode; | 42 class ContainerNode; |
42 class Document; | 43 class Document; |
43 class DocumentFragment; | 44 class DocumentFragment; |
44 class ExceptionState; | 45 class ExceptionState; |
45 class FloatQuad; | 46 class FloatQuad; |
46 class Node; | 47 class Node; |
47 class NodeWithIndex; | 48 class NodeWithIndex; |
48 class Text; | 49 class Text; |
49 | 50 |
50 class Range : public RefCounted<Range>, public ScriptWrappable { | 51 class Range FINAL : public RefCountedWillBeGarbageCollectedFinalized<Range>, pub
lic ScriptWrappable { |
51 public: | 52 public: |
52 static PassRefPtr<Range> create(Document&); | 53 static PassRefPtrWillBeRawPtr<Range> create(Document&); |
53 static PassRefPtr<Range> create(Document&, Node* startContainer, int startOf
fset, Node* endContainer, int endOffset); | 54 static PassRefPtrWillBeRawPtr<Range> create(Document&, Node* startContainer,
int startOffset, Node* endContainer, int endOffset); |
54 static PassRefPtr<Range> create(Document&, const Position&, const Position&)
; | 55 static PassRefPtrWillBeRawPtr<Range> create(Document&, const Position&, cons
t Position&); |
55 ~Range(); | 56 ~Range(); |
56 | 57 |
57 Document& ownerDocument() const { ASSERT(m_ownerDocument); return *m_ownerDo
cument.get(); } | 58 Document& ownerDocument() const { ASSERT(m_ownerDocument); return *m_ownerDo
cument.get(); } |
58 Node* startContainer() const { return m_start.container(); } | 59 Node* startContainer() const { return m_start.container(); } |
59 int startOffset() const { return m_start.offset(); } | 60 int startOffset() const { return m_start.offset(); } |
60 Node* endContainer() const { return m_end.container(); } | 61 Node* endContainer() const { return m_end.container(); } |
61 int endOffset() const { return m_end.offset(); } | 62 int endOffset() const { return m_end.offset(); } |
62 | 63 |
63 Node* startContainer(ExceptionState&) const; | 64 Node* startContainer(ExceptionState&) const; |
64 int startOffset(ExceptionState&) const; | 65 int startOffset(ExceptionState&) const; |
(...skipping 21 matching lines...) Expand all Loading... |
86 PassRefPtr<DocumentFragment> cloneContents(ExceptionState&); | 87 PassRefPtr<DocumentFragment> cloneContents(ExceptionState&); |
87 void insertNode(PassRefPtr<Node>, ExceptionState&); | 88 void insertNode(PassRefPtr<Node>, ExceptionState&); |
88 String toString(ExceptionState&) const; | 89 String toString(ExceptionState&) const; |
89 | 90 |
90 String toHTML() const; | 91 String toHTML() const; |
91 String text() const; | 92 String text() const; |
92 | 93 |
93 PassRefPtr<DocumentFragment> createContextualFragment(const String& html, Ex
ceptionState&); | 94 PassRefPtr<DocumentFragment> createContextualFragment(const String& html, Ex
ceptionState&); |
94 | 95 |
95 void detach(ExceptionState&); | 96 void detach(ExceptionState&); |
96 PassRefPtr<Range> cloneRange(ExceptionState&) const; | 97 PassRefPtrWillBeRawPtr<Range> cloneRange(ExceptionState&) const; |
97 | 98 |
98 void setStartAfter(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); | 99 void setStartAfter(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); |
99 void setEndBefore(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); | 100 void setEndBefore(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); |
100 void setEndAfter(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); | 101 void setEndAfter(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); |
101 void selectNode(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); | 102 void selectNode(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); |
102 void selectNodeContents(Node*, ExceptionState&); | 103 void selectNodeContents(Node*, ExceptionState&); |
103 void surroundContents(PassRefPtr<Node>, ExceptionState&); | 104 void surroundContents(PassRefPtr<Node>, ExceptionState&); |
104 void setStartBefore(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); | 105 void setStartBefore(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); |
105 | 106 |
106 const Position startPosition() const { return m_start.toPosition(); } | 107 const Position startPosition() const { return m_start.toPosition(); } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // for details. | 143 // for details. |
143 void expand(const String&, ExceptionState&); | 144 void expand(const String&, ExceptionState&); |
144 | 145 |
145 PassRefPtr<ClientRectList> getClientRects() const; | 146 PassRefPtr<ClientRectList> getClientRects() const; |
146 PassRefPtr<ClientRect> getBoundingClientRect() const; | 147 PassRefPtr<ClientRect> getBoundingClientRect() const; |
147 | 148 |
148 #ifndef NDEBUG | 149 #ifndef NDEBUG |
149 void formatForDebugger(char* buffer, unsigned length) const; | 150 void formatForDebugger(char* buffer, unsigned length) const; |
150 #endif | 151 #endif |
151 | 152 |
| 153 void trace(Visitor*); |
| 154 |
152 private: | 155 private: |
153 explicit Range(Document&); | 156 explicit Range(Document&); |
154 Range(Document&, Node* startContainer, int startOffset, Node* endContainer,
int endOffset); | 157 Range(Document&, Node* startContainer, int startOffset, Node* endContainer,
int endOffset); |
155 | 158 |
156 void setDocument(Document&); | 159 void setDocument(Document&); |
157 | 160 |
158 Node* checkNodeWOffset(Node*, int offset, ExceptionState&) const; | 161 Node* checkNodeWOffset(Node*, int offset, ExceptionState&) const; |
159 void checkNodeBA(Node*, ExceptionState&) const; | 162 void checkNodeBA(Node*, ExceptionState&) const; |
160 void checkDeleteExtract(ExceptionState&); | 163 void checkDeleteExtract(ExceptionState&); |
161 int maxStartOffset() const; | 164 int maxStartOffset() const; |
162 int maxEndOffset() const; | 165 int maxEndOffset() const; |
163 | 166 |
164 enum ActionType { DELETE_CONTENTS, EXTRACT_CONTENTS, CLONE_CONTENTS }; | 167 enum ActionType { DELETE_CONTENTS, EXTRACT_CONTENTS, CLONE_CONTENTS }; |
165 PassRefPtr<DocumentFragment> processContents(ActionType, ExceptionState&); | 168 PassRefPtr<DocumentFragment> processContents(ActionType, ExceptionState&); |
166 static PassRefPtr<Node> processContentsBetweenOffsets(ActionType, PassRefPtr
<DocumentFragment>, Node*, unsigned startOffset, unsigned endOffset, ExceptionSt
ate&); | 169 static PassRefPtr<Node> processContentsBetweenOffsets(ActionType, PassRefPtr
<DocumentFragment>, Node*, unsigned startOffset, unsigned endOffset, ExceptionSt
ate&); |
167 static void processNodes(ActionType, Vector<RefPtr<Node> >&, PassRefPtr<Node
> oldContainer, PassRefPtr<Node> newContainer, ExceptionState&); | 170 static void processNodes(ActionType, Vector<RefPtr<Node> >&, PassRefPtr<Node
> oldContainer, PassRefPtr<Node> newContainer, ExceptionState&); |
168 enum ContentsProcessDirection { ProcessContentsForward, ProcessContentsBackw
ard }; | 171 enum ContentsProcessDirection { ProcessContentsForward, ProcessContentsBackw
ard }; |
169 static PassRefPtr<Node> processAncestorsAndTheirSiblings(ActionType, Node* c
ontainer, ContentsProcessDirection, PassRefPtr<Node> clonedContainer, Node* comm
onRoot, ExceptionState&); | 172 static PassRefPtr<Node> processAncestorsAndTheirSiblings(ActionType, Node* c
ontainer, ContentsProcessDirection, PassRefPtr<Node> clonedContainer, Node* comm
onRoot, ExceptionState&); |
170 | 173 |
171 RefPtr<Document> m_ownerDocument; // Cannot be null. | 174 RefPtr<Document> m_ownerDocument; // Cannot be null. |
172 RangeBoundaryPoint m_start; | 175 RangeBoundaryPoint m_start; |
173 RangeBoundaryPoint m_end; | 176 RangeBoundaryPoint m_end; |
174 }; | 177 }; |
175 | 178 |
176 PassRefPtr<Range> rangeOfContents(Node*); | 179 PassRefPtrWillBeRawPtr<Range> rangeOfContents(Node*); |
177 | 180 |
178 bool areRangesEqual(const Range*, const Range*); | 181 bool areRangesEqual(const Range*, const Range*); |
179 | 182 |
180 } // namespace | 183 } // namespace |
181 | 184 |
182 #ifndef NDEBUG | 185 #ifndef NDEBUG |
183 // Outside the WebCore namespace for ease of invocation from gdb. | 186 // Outside the WebCore namespace for ease of invocation from gdb. |
184 void showTree(const WebCore::Range*); | 187 void showTree(const WebCore::Range*); |
185 #endif | 188 #endif |
186 | 189 |
187 #endif | 190 #endif |
OLD | NEW |