| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 class Document; | 43 class Document; |
| 44 class DocumentFragment; | 44 class DocumentFragment; |
| 45 class ExceptionState; | 45 class ExceptionState; |
| 46 class FloatQuad; | 46 class FloatQuad; |
| 47 class Node; | 47 class Node; |
| 48 class NodeWithIndex; | 48 class NodeWithIndex; |
| 49 class Text; | 49 class Text; |
| 50 | 50 |
| 51 class CORE_EXPORT Range final | 51 class CORE_EXPORT Range final |
| 52 #ifndef NDEBUG | 52 #ifndef NDEBUG |
| 53 : public RefCountedWillBeGarbageCollectedFinalized<Range> | 53 : public GarbageCollectedFinalized<Range> |
| 54 #else | 54 #else |
| 55 : public RefCountedWillBeGarbageCollected<Range> | 55 : public GarbageCollected<Range> |
| 56 #endif | 56 #endif |
| 57 , public ScriptWrappable { | 57 , public ScriptWrappable { |
| 58 DEFINE_WRAPPERTYPEINFO(); | 58 DEFINE_WRAPPERTYPEINFO(); |
| 59 public: | 59 public: |
| 60 static PassRefPtrWillBeRawPtr<Range> create(Document&); | 60 static RawPtr<Range> create(Document&); |
| 61 static PassRefPtrWillBeRawPtr<Range> create(Document&, Node* startContainer,
int startOffset, Node* endContainer, int endOffset); | 61 static RawPtr<Range> create(Document&, Node* startContainer, int startOffset
, Node* endContainer, int endOffset); |
| 62 static PassRefPtrWillBeRawPtr<Range> create(Document&, const Position&, cons
t Position&); | 62 static RawPtr<Range> create(Document&, const Position&, const Position&); |
| 63 static PassRefPtrWillBeRawPtr<Range> createAdjustedToTreeScope(const TreeSco
pe&, const Position&); | 63 static RawPtr<Range> createAdjustedToTreeScope(const TreeScope&, const Posit
ion&); |
| 64 #if !ENABLE(OILPAN) || !defined(NDEBUG) | 64 #if !ENABLE(OILPAN) || !defined(NDEBUG) |
| 65 ~Range(); | 65 ~Range(); |
| 66 #endif | 66 #endif |
| 67 void dispose(); | 67 void dispose(); |
| 68 | 68 |
| 69 Document& ownerDocument() const { ASSERT(m_ownerDocument); return *m_ownerDo
cument.get(); } | 69 Document& ownerDocument() const { ASSERT(m_ownerDocument); return *m_ownerDo
cument.get(); } |
| 70 Node* startContainer() const { return m_start.container(); } | 70 Node* startContainer() const { return m_start.container(); } |
| 71 int startOffset() const { return m_start.offset(); } | 71 int startOffset() const { return m_start.offset(); } |
| 72 Node* endContainer() const { return m_end.container(); } | 72 Node* endContainer() const { return m_end.container(); } |
| 73 int endOffset() const { return m_end.offset(); } | 73 int endOffset() const { return m_end.offset(); } |
| 74 | 74 |
| 75 bool collapsed() const { return m_start == m_end; } | 75 bool collapsed() const { return m_start == m_end; } |
| 76 bool inDocument() const; | 76 bool inDocument() const; |
| 77 | 77 |
| 78 Node* commonAncestorContainer() const; | 78 Node* commonAncestorContainer() const; |
| 79 static Node* commonAncestorContainer(const Node* containerA, const Node* con
tainerB); | 79 static Node* commonAncestorContainer(const Node* containerA, const Node* con
tainerB); |
| 80 void setStart(PassRefPtrWillBeRawPtr<Node> container, int offset, ExceptionS
tate& = ASSERT_NO_EXCEPTION); | 80 void setStart(RawPtr<Node> container, int offset, ExceptionState& = ASSERT_N
O_EXCEPTION); |
| 81 void setEnd(PassRefPtrWillBeRawPtr<Node> container, int offset, ExceptionSta
te& = ASSERT_NO_EXCEPTION); | 81 void setEnd(RawPtr<Node> container, int offset, ExceptionState& = ASSERT_NO_
EXCEPTION); |
| 82 void collapse(bool toStart); | 82 void collapse(bool toStart); |
| 83 bool isNodeFullyContained(Node&) const; | 83 bool isNodeFullyContained(Node&) const; |
| 84 bool isPointInRange(Node* refNode, int offset, ExceptionState&) const; | 84 bool isPointInRange(Node* refNode, int offset, ExceptionState&) const; |
| 85 short comparePoint(Node* refNode, int offset, ExceptionState&) const; | 85 short comparePoint(Node* refNode, int offset, ExceptionState&) const; |
| 86 enum CompareResults { NODE_BEFORE, NODE_AFTER, NODE_BEFORE_AND_AFTER, NODE_I
NSIDE }; | 86 enum CompareResults { NODE_BEFORE, NODE_AFTER, NODE_BEFORE_AND_AFTER, NODE_I
NSIDE }; |
| 87 enum CompareHow { START_TO_START, START_TO_END, END_TO_END, END_TO_START }; | 87 enum CompareHow { START_TO_START, START_TO_END, END_TO_END, END_TO_START }; |
| 88 short compareBoundaryPoints(unsigned how, const Range* sourceRange, Exceptio
nState&) const; | 88 short compareBoundaryPoints(unsigned how, const Range* sourceRange, Exceptio
nState&) const; |
| 89 static short compareBoundaryPoints(Node* containerA, int offsetA, Node* cont
ainerB, int offsetB, ExceptionState&); | 89 static short compareBoundaryPoints(Node* containerA, int offsetA, Node* cont
ainerB, int offsetB, ExceptionState&); |
| 90 static short compareBoundaryPoints(const RangeBoundaryPoint& boundaryA, cons
t RangeBoundaryPoint& boundaryB, ExceptionState&); | 90 static short compareBoundaryPoints(const RangeBoundaryPoint& boundaryA, cons
t RangeBoundaryPoint& boundaryB, ExceptionState&); |
| 91 bool boundaryPointsValid() const; | 91 bool boundaryPointsValid() const; |
| 92 bool intersectsNode(Node* refNode, ExceptionState&); | 92 bool intersectsNode(Node* refNode, ExceptionState&); |
| 93 static bool intersectsNode(Node* refNode, const Position& start, const Posit
ion& end, ExceptionState&); | 93 static bool intersectsNode(Node* refNode, const Position& start, const Posit
ion& end, ExceptionState&); |
| 94 void deleteContents(ExceptionState&); | 94 void deleteContents(ExceptionState&); |
| 95 PassRefPtrWillBeRawPtr<DocumentFragment> extractContents(ExceptionState&); | 95 RawPtr<DocumentFragment> extractContents(ExceptionState&); |
| 96 PassRefPtrWillBeRawPtr<DocumentFragment> cloneContents(ExceptionState&); | 96 RawPtr<DocumentFragment> cloneContents(ExceptionState&); |
| 97 void insertNode(PassRefPtrWillBeRawPtr<Node>, ExceptionState&); | 97 void insertNode(RawPtr<Node>, ExceptionState&); |
| 98 String toString() const; | 98 String toString() const; |
| 99 | 99 |
| 100 String text() const; | 100 String text() const; |
| 101 | 101 |
| 102 PassRefPtrWillBeRawPtr<DocumentFragment> createContextualFragment(const Stri
ng& html, ExceptionState&); | 102 RawPtr<DocumentFragment> createContextualFragment(const String& html, Except
ionState&); |
| 103 | 103 |
| 104 void detach(); | 104 void detach(); |
| 105 PassRefPtrWillBeRawPtr<Range> cloneRange() const; | 105 RawPtr<Range> cloneRange() const; |
| 106 | 106 |
| 107 void setStartAfter(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); | 107 void setStartAfter(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); |
| 108 void setEndBefore(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); | 108 void setEndBefore(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); |
| 109 void setEndAfter(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); | 109 void setEndAfter(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); |
| 110 void selectNode(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); | 110 void selectNode(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); |
| 111 void selectNodeContents(Node*, ExceptionState&); | 111 void selectNodeContents(Node*, ExceptionState&); |
| 112 static bool selectNodeContents(Node*, Position&, Position&); | 112 static bool selectNodeContents(Node*, Position&, Position&); |
| 113 void surroundContents(PassRefPtrWillBeRawPtr<Node>, ExceptionState&); | 113 void surroundContents(RawPtr<Node>, ExceptionState&); |
| 114 void setStartBefore(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); | 114 void setStartBefore(Node*, ExceptionState& = ASSERT_NO_EXCEPTION); |
| 115 | 115 |
| 116 const Position startPosition() const { return m_start.toPosition(); } | 116 const Position startPosition() const { return m_start.toPosition(); } |
| 117 const Position endPosition() const { return m_end.toPosition(); } | 117 const Position endPosition() const { return m_end.toPosition(); } |
| 118 void setStart(const Position&, ExceptionState& = ASSERT_NO_EXCEPTION); | 118 void setStart(const Position&, ExceptionState& = ASSERT_NO_EXCEPTION); |
| 119 void setEnd(const Position&, ExceptionState& = ASSERT_NO_EXCEPTION); | 119 void setEnd(const Position&, ExceptionState& = ASSERT_NO_EXCEPTION); |
| 120 | 120 |
| 121 Node* firstNode() const; | 121 Node* firstNode() const; |
| 122 Node* pastLastNode() const; | 122 Node* pastLastNode() const; |
| 123 | 123 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 explicit Range(Document&); | 160 explicit Range(Document&); |
| 161 Range(Document&, Node* startContainer, int startOffset, Node* endContainer,
int endOffset); | 161 Range(Document&, Node* startContainer, int startOffset, Node* endContainer,
int endOffset); |
| 162 | 162 |
| 163 void setDocument(Document&); | 163 void setDocument(Document&); |
| 164 | 164 |
| 165 Node* checkNodeWOffset(Node*, int offset, ExceptionState&) const; | 165 Node* checkNodeWOffset(Node*, int offset, ExceptionState&) const; |
| 166 void checkNodeBA(Node*, ExceptionState&) const; | 166 void checkNodeBA(Node*, ExceptionState&) const; |
| 167 void checkExtractPrecondition(ExceptionState&); | 167 void checkExtractPrecondition(ExceptionState&); |
| 168 | 168 |
| 169 enum ActionType { DELETE_CONTENTS, EXTRACT_CONTENTS, CLONE_CONTENTS }; | 169 enum ActionType { DELETE_CONTENTS, EXTRACT_CONTENTS, CLONE_CONTENTS }; |
| 170 PassRefPtrWillBeRawPtr<DocumentFragment> processContents(ActionType, Excepti
onState&); | 170 RawPtr<DocumentFragment> processContents(ActionType, ExceptionState&); |
| 171 static PassRefPtrWillBeRawPtr<Node> processContentsBetweenOffsets(ActionType
, PassRefPtrWillBeRawPtr<DocumentFragment>, Node*, unsigned startOffset, unsigne
d endOffset, ExceptionState&); | 171 static RawPtr<Node> processContentsBetweenOffsets(ActionType, RawPtr<Documen
tFragment>, Node*, unsigned startOffset, unsigned endOffset, ExceptionState&); |
| 172 static void processNodes(ActionType, WillBeHeapVector<RefPtrWillBeMember<Nod
e>>&, PassRefPtrWillBeRawPtr<Node> oldContainer, PassRefPtrWillBeRawPtr<Node> ne
wContainer, ExceptionState&); | 172 static void processNodes(ActionType, HeapVector<Member<Node>>&, RawPtr<Node>
oldContainer, RawPtr<Node> newContainer, ExceptionState&); |
| 173 enum ContentsProcessDirection { ProcessContentsForward, ProcessContentsBackw
ard }; | 173 enum ContentsProcessDirection { ProcessContentsForward, ProcessContentsBackw
ard }; |
| 174 static PassRefPtrWillBeRawPtr<Node> processAncestorsAndTheirSiblings(ActionT
ype, Node* container, ContentsProcessDirection, PassRefPtrWillBeRawPtr<Node> clo
nedContainer, Node* commonRoot, ExceptionState&); | 174 static RawPtr<Node> processAncestorsAndTheirSiblings(ActionType, Node* conta
iner, ContentsProcessDirection, RawPtr<Node> clonedContainer, Node* commonRoot,
ExceptionState&); |
| 175 | 175 |
| 176 RefPtrWillBeMember<Document> m_ownerDocument; // Cannot be null. | 176 Member<Document> m_ownerDocument; // Cannot be null. |
| 177 RangeBoundaryPoint m_start; | 177 RangeBoundaryPoint m_start; |
| 178 RangeBoundaryPoint m_end; | 178 RangeBoundaryPoint m_end; |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 CORE_EXPORT bool areRangesEqual(const Range*, const Range*); | 181 CORE_EXPORT bool areRangesEqual(const Range*, const Range*); |
| 182 | 182 |
| 183 } // namespace blink | 183 } // namespace blink |
| 184 | 184 |
| 185 #ifndef NDEBUG | 185 #ifndef NDEBUG |
| 186 // Outside the WebCore namespace for ease of invocation from gdb. | 186 // Outside the WebCore namespace for ease of invocation from gdb. |
| 187 void showTree(const blink::Range*); | 187 void showTree(const blink::Range*); |
| 188 #endif | 188 #endif |
| 189 | 189 |
| 190 #endif // Range_h | 190 #endif // Range_h |
| OLD | NEW |