Changeset 157018 in webkit
- Timestamp:
- Oct 6, 2013 8:39:12 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 38 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r156972 r157018 1 2013-10-06 Andreas Kling <akling@apple.com> 2 3 Range constructors should take a Document&. 4 <https://webkit.org/b/122435> 5 6 Reviewed by Sam Weinig. 7 8 Give Ref an assignment operator. 9 1 10 2013-10-05 Anders Carlsson <andersca@apple.com> 2 11 -
trunk/Source/WTF/wtf/Ref.h
r155805 r157018 34 34 public: 35 35 Ref(T& object) : m_ptr(&object) { m_ptr->ref(); } 36 Ref& operator=(T& object) 37 { 38 object.ref(); 39 m_ptr->deref(); 40 m_ptr = &object; 41 return *this; 42 } 36 43 37 44 ~Ref() { m_ptr->deref(); } -
trunk/Source/WebCore/ChangeLog
r157015 r157018 1 2013-10-06 Andreas Kling <akling@apple.com> 2 3 Range constructors should take a Document&. 4 <https://webkit.org/b/122435> 5 6 Reviewed by Sam Weinig. 7 8 Make all Range constructors take Document& instead of a PassRefPtr. 9 This removes one null check at every call site. 10 11 Also use a Ref<Document> for storage in Range. 12 1 13 2013-10-06 Antti Koivisto <antti@apple.com> 2 14 -
trunk/Source/WebCore/WebCore.exp.in
r157002 r157018 930 930 __ZN7WebCore5Range14setStartBeforeEPNS_4NodeERi 931 931 __ZN7WebCore5Range18selectNodeContentsEPNS_4NodeERi 932 __ZN7WebCore5Range6createE N3WTF10PassRefPtrINS_8DocumentEEE933 __ZN7WebCore5Range6createE N3WTF10PassRefPtrINS_8DocumentEEENS2_INS_4NodeEEEiS6_i932 __ZN7WebCore5Range6createERNS_8DocumentE 933 __ZN7WebCore5Range6createERNS_8DocumentEN3WTF10PassRefPtrINS_4NodeEEEiS6_i 934 934 __ZN7WebCore5Range6setEndEN3WTF10PassRefPtrINS_4NodeEEEiRi 935 935 __ZN7WebCore5Range8collapseEbRi -
trunk/Source/WebCore/accessibility/atk/AXObjectCacheAtk.cpp
r155507 r157018 215 215 // the current accessibility object to ensure we emit the 216 216 // right offset (e.g. multiline text areas). 217 RefPtr<Range> range = Range::create( &document, node->parentNode(), 0, node, 0);217 RefPtr<Range> range = Range::create(document, node->parentNode(), 0, node, 0); 218 218 offsetToEmit = offset + TextIterator::rangeLength(range.get()); 219 219 } -
trunk/Source/WebCore/accessibility/atk/WebKitAccessibleHyperlink.cpp
r156532 r157018 261 261 return 0; 262 262 263 RefPtr<Range> range = Range::create( &node->document(), firstPositionInOrBeforeNode(parentNode), firstPositionInOrBeforeNode(node));263 RefPtr<Range> range = Range::create(node->document(), firstPositionInOrBeforeNode(parentNode), firstPositionInOrBeforeNode(node)); 264 264 return getRangeLengthForObject(coreObject, range.get()); 265 265 } … … 287 287 return 0; 288 288 289 RefPtr<Range> range = Range::create( &node->document(), firstPositionInOrBeforeNode(parentNode), lastPositionInOrAfterNode(node));289 RefPtr<Range> range = Range::create(node->document(), firstPositionInOrBeforeNode(parentNode), lastPositionInOrAfterNode(node)); 290 290 return getRangeLengthForObject(coreObject, range.get()); 291 291 } -
trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp
r156835 r157018 533 533 // Calculate position of the selected range inside the object. 534 534 Position parentFirstPosition = firstPositionInOrBeforeNode(node); 535 RefPtr<Range> rangeInParent = Range::create( &node->document(), parentFirstPosition, nodeRangeStart);535 RefPtr<Range> rangeInParent = Range::create(node->document(), parentFirstPosition, nodeRangeStart); 536 536 537 537 // Set values for start offsets and calculate initial range length. 538 538 // These values might be adjusted later to cover special cases. 539 539 startOffset = webCoreOffsetToAtkOffset(coreObject, TextIterator::rangeLength(rangeInParent.get(), true)); 540 RefPtr<Range> nodeRange = Range::create( &node->document(), nodeRangeStart, nodeRangeEnd);540 RefPtr<Range> nodeRange = Range::create(node->document(), nodeRangeStart, nodeRangeEnd); 541 541 int rangeLength = TextIterator::rangeLength(nodeRange.get(), true); 542 542 -
trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
r156550 r157018 1652 1652 return NSMakeRange(NSNotFound, 0); 1653 1653 1654 RefPtr<Range> testRange = Range::create( &scope->document(), scope, 0, range->startContainer(), range->startOffset());1654 RefPtr<Range> testRange = Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset()); 1655 1655 ASSERT(testRange->startContainer() == scope); 1656 1656 int startPosition = TextIterator::rangeLength(testRange.get()); -
trunk/Source/WebCore/dom/Document.cpp
r157002 r157018 1462 1462 unsigned offset = shadowAncestorNode->nodeIndex(); 1463 1463 ContainerNode* container = shadowAncestorNode->parentNode(); 1464 return Range::create( this, container, offset, container, offset);1464 return Range::create(*this, container, offset, container, offset); 1465 1465 } 1466 1466 … … 1473 1473 1474 1474 Position rangeCompliantPosition = visiblePosition.deepEquivalent().parentAnchoredEquivalent(); 1475 return Range::create( this, rangeCompliantPosition, rangeCompliantPosition);1475 return Range::create(*this, rangeCompliantPosition, rangeCompliantPosition); 1476 1476 } 1477 1477 … … 1689 1689 PassRefPtr<Range> Document::createRange() 1690 1690 { 1691 return Range::create( this);1691 return Range::create(*this); 1692 1692 } 1693 1693 -
trunk/Source/WebCore/dom/Node.cpp
r156986 r157018 2278 2278 void Node::textRects(Vector<IntRect>& rects) const 2279 2279 { 2280 RefPtr<Range> range = Range::create( &document());2280 RefPtr<Range> range = Range::create(document()); 2281 2281 range->selectNodeContents(const_cast<Node*>(this), IGNORE_EXCEPTION); 2282 2282 range->textRects(rects); -
trunk/Source/WebCore/dom/Range.cpp
r157002 r157018 63 63 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, rangeCounter, ("Range")); 64 64 65 inline Range::Range( PassRefPtr<Document>ownerDocument)65 inline Range::Range(Document& ownerDocument) 66 66 : m_ownerDocument(ownerDocument) 67 , m_start( m_ownerDocument)68 , m_end( m_ownerDocument)67 , m_start(&ownerDocument) 68 , m_end(&ownerDocument) 69 69 { 70 70 #ifndef NDEBUG … … 75 75 } 76 76 77 PassRefPtr<Range> Range::create( PassRefPtr<Document>ownerDocument)77 PassRefPtr<Range> Range::create(Document& ownerDocument) 78 78 { 79 79 return adoptRef(new Range(ownerDocument)); 80 80 } 81 81 82 inline Range::Range( PassRefPtr<Document>ownerDocument, PassRefPtr<Node> startContainer, int startOffset, PassRefPtr<Node> endContainer, int endOffset)82 inline Range::Range(Document& ownerDocument, PassRefPtr<Node> startContainer, int startOffset, PassRefPtr<Node> endContainer, int endOffset) 83 83 : m_ownerDocument(ownerDocument) 84 , m_start( m_ownerDocument)85 , m_end( m_ownerDocument)84 , m_start(&ownerDocument) 85 , m_end(&ownerDocument) 86 86 { 87 87 #ifndef NDEBUG … … 97 97 } 98 98 99 PassRefPtr<Range> Range::create( PassRefPtr<Document>ownerDocument, PassRefPtr<Node> startContainer, int startOffset, PassRefPtr<Node> endContainer, int endOffset)99 PassRefPtr<Range> Range::create(Document& ownerDocument, PassRefPtr<Node> startContainer, int startOffset, PassRefPtr<Node> endContainer, int endOffset) 100 100 { 101 101 return adoptRef(new Range(ownerDocument, startContainer, startOffset, endContainer, endOffset)); 102 102 } 103 103 104 PassRefPtr<Range> Range::create( PassRefPtr<Document>ownerDocument, const Position& start, const Position& end)104 PassRefPtr<Range> Range::create(Document& ownerDocument, const Position& start, const Position& end) 105 105 { 106 106 return adoptRef(new Range(ownerDocument, start.containerNode(), start.computeOffsetInContainerNode(), end.containerNode(), end.computeOffsetInContainerNode())); … … 119 119 void Range::setDocument(Document& document) 120 120 { 121 ASSERT(m_ownerDocument != &document); 122 if (m_ownerDocument) 123 m_ownerDocument->detachRange(this); 124 m_ownerDocument = &document; 121 ASSERT(&m_ownerDocument.get() != &document); 122 m_ownerDocument->detachRange(this); 123 m_ownerDocument = document; 125 124 m_start.setToStartOfNode(&document); 126 125 m_end.setToStartOfNode(&document); … … 224 223 225 224 bool didMoveDocument = false; 226 if (&refNode->document() != m_ownerDocument) {225 if (&refNode->document() != &ownerDocument()) { 227 226 setDocument(refNode->document()); 228 227 didMoveDocument = true; … … 253 252 254 253 bool didMoveDocument = false; 255 if (&refNode->document() != m_ownerDocument) {254 if (&refNode->document() != &ownerDocument()) { 256 255 setDocument(refNode->document()); 257 256 didMoveDocument = true; … … 306 305 } 307 306 308 if (!refNode->attached() || &refNode->document() != m_ownerDocument) {307 if (!refNode->attached() || &refNode->document() != &ownerDocument()) { 309 308 return false; 310 309 } … … 335 334 } 336 335 337 if (!refNode->attached() || &refNode->document() != m_ownerDocument) {336 if (!refNode->attached() || &refNode->document() != &ownerDocument()) { 338 337 ec = WRONG_DOCUMENT_ERR; 339 338 return 0; … … 381 380 } 382 381 383 if (&refNode->document() != m_ownerDocument) {382 if (&refNode->document() != &ownerDocument()) { 384 383 // Firefox doesn't throw an exception for this case; it returns 0. 385 384 return NODE_BEFORE; … … 586 585 } 587 586 588 if (!refNode->attached() || &refNode->document() != m_ownerDocument) {587 if (!refNode->attached() || &refNode->document() != &ownerDocument()) { 589 588 // Firefox doesn't throw an exception for these cases; it returns false. 590 589 return false; … … 1226 1225 } 1227 1226 1228 return Range::create( m_ownerDocument, m_start.container(), m_start.offset(), m_end.container(), m_end.offset());1227 return Range::create(ownerDocument(), m_start.container(), m_start.offset(), m_end.container(), m_end.offset()); 1229 1228 } 1230 1229 … … 1344 1343 } 1345 1344 1346 if ( m_ownerDocument!= &refNode->document())1345 if (&ownerDocument() != &refNode->document()) 1347 1346 setDocument(refNode->document()); 1348 1347 … … 1389 1388 } 1390 1389 1391 if ( m_ownerDocument!= &refNode->document())1390 if (&ownerDocument() != &refNode->document()) 1392 1391 setDocument(refNode->document()); 1393 1392 … … 1702 1701 { 1703 1702 ASSERT(node); 1704 RefPtr<Range> range = Range::create( &node->document());1703 RefPtr<Range> range = Range::create(node->document()); 1705 1704 int exception = 0; 1706 1705 range->selectNodeContents(node, exception); … … 1737 1736 void Range::nodeChildrenChanged(ContainerNode& container) 1738 1737 { 1739 ASSERT(&container.document() == m_ownerDocument);1738 ASSERT(&container.document() == &ownerDocument()); 1740 1739 boundaryNodeChildrenChanged(m_start, container); 1741 1740 boundaryNodeChildrenChanged(m_end, container); … … 1761 1760 void Range::nodeChildrenWillBeRemoved(ContainerNode& container) 1762 1761 { 1763 ASSERT(&container.document() == m_ownerDocument);1762 ASSERT(&container.document() == &ownerDocument()); 1764 1763 boundaryNodeChildrenWillBeRemoved(m_start, container); 1765 1764 boundaryNodeChildrenWillBeRemoved(m_end, container); … … 1784 1783 { 1785 1784 ASSERT(node); 1786 ASSERT(&node->document() == m_ownerDocument);1787 ASSERT(node != m_ownerDocument);1785 ASSERT(&node->document() == &ownerDocument()); 1786 ASSERT(node != &ownerDocument()); 1788 1787 ASSERT(node->parentNode()); 1789 1788 boundaryNodeWillBeRemoved(m_start, node); … … 1804 1803 { 1805 1804 ASSERT(text); 1806 ASSERT(&text->document() == m_ownerDocument);1805 ASSERT(&text->document() == &ownerDocument()); 1807 1806 boundaryTextInserted(m_start, text, offset, length); 1808 1807 boundaryTextInserted(m_end, text, offset, length); … … 1825 1824 { 1826 1825 ASSERT(text); 1827 ASSERT(&text->document() == m_ownerDocument);1826 ASSERT(&text->document() == &ownerDocument()); 1828 1827 boundaryTextRemoved(m_start, text, offset, length); 1829 1828 boundaryTextRemoved(m_end, text, offset, length); … … 1841 1840 { 1842 1841 ASSERT(oldNode.node()); 1843 ASSERT(&oldNode.node()->document() == m_ownerDocument);1842 ASSERT(&oldNode.node()->document() == &ownerDocument()); 1844 1843 ASSERT(oldNode.node()->parentNode()); 1845 1844 ASSERT(oldNode.node()->isTextNode()); … … 1863 1862 { 1864 1863 ASSERT(oldNode); 1865 ASSERT(&oldNode->document() == m_ownerDocument);1864 ASSERT(&oldNode->document() == &ownerDocument()); 1866 1865 ASSERT(oldNode->parentNode()); 1867 1866 ASSERT(oldNode->isTextNode()); … … 1899 1898 return ClientRectList::create(); 1900 1899 1901 m_ownerDocument->updateLayoutIgnorePendingStylesheets();1900 ownerDocument().updateLayoutIgnorePendingStylesheets(); 1902 1901 1903 1902 Vector<FloatQuad> quads; … … 1934 1933 Vector<FloatQuad> elementQuads; 1935 1934 renderBoxModelObject->absoluteQuads(elementQuads); 1936 m_ownerDocument->adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(elementQuads, renderBoxModelObject);1935 ownerDocument().adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(elementQuads, renderBoxModelObject); 1937 1936 1938 1937 quads.appendVector(elementQuads); … … 1946 1945 Vector<FloatQuad> textQuads; 1947 1946 renderText->absoluteQuadsForRange(textQuads, startOffset, endOffset); 1948 m_ownerDocument->adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(textQuads, renderText);1947 ownerDocument().adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(textQuads, renderText); 1949 1948 1950 1949 quads.appendVector(textQuads); … … 1959 1958 return FloatRect(); 1960 1959 1961 m_ownerDocument->updateLayoutIgnorePendingStylesheets();1960 ownerDocument().updateLayoutIgnorePendingStylesheets(); 1962 1961 1963 1962 Vector<FloatQuad> quads; -
trunk/Source/WebCore/dom/Range.h
r156256 r157018 49 49 class Range : public RefCounted<Range> { 50 50 public: 51 static PassRefPtr<Range> create( PassRefPtr<Document>);52 static PassRefPtr<Range> create( PassRefPtr<Document>, PassRefPtr<Node> startContainer, int startOffset, PassRefPtr<Node> endContainer, int endOffset);53 static PassRefPtr<Range> create( PassRefPtr<Document>, const Position&, const Position&);51 static PassRefPtr<Range> create(Document&); 52 static PassRefPtr<Range> create(Document&, PassRefPtr<Node> startContainer, int startOffset, PassRefPtr<Node> endContainer, int endOffset); 53 static PassRefPtr<Range> create(Document&, const Position&, const Position&); 54 54 ~Range(); 55 55 56 Document& ownerDocument() const { return *m_ownerDocument; } 56 Document& ownerDocument() const { return const_cast<Document&>(m_ownerDocument.get()); } 57 57 58 Node* startContainer() const { return m_start.container(); } 58 59 int startOffset() const { return m_start.offset(); } … … 150 151 151 152 private: 152 explicit Range( PassRefPtr<Document>);153 Range( PassRefPtr<Document>, PassRefPtr<Node> startContainer, int startOffset, PassRefPtr<Node> endContainer, int endOffset);153 explicit Range(Document&); 154 Range(Document&, PassRefPtr<Node> startContainer, int startOffset, PassRefPtr<Node> endContainer, int endOffset); 154 155 155 156 void setDocument(Document&); … … 169 170 static PassRefPtr<Node> processAncestorsAndTheirSiblings(ActionType, Node* container, ContentsProcessDirection, PassRefPtr<Node> clonedContainer, Node* commonRoot, ExceptionCode&); 170 171 171 Ref Ptr<Document> m_ownerDocument;172 Ref<Document> m_ownerDocument; 172 173 RangeBoundaryPoint m_start; 173 174 RangeBoundaryPoint m_end; -
trunk/Source/WebCore/editing/AlternativeTextController.cpp
r156372 r157018 263 263 // to store this value. In order to obtain this offset, we need to first create a range 264 264 // which spans from the start of paragraph to the start position of rangeWithAlternative. 265 RefPtr<Range> correctionStartOffsetInParagraphAsRange = Range::create( ¶graphRangeContainingCorrection->startContainer(ec)->document(), paragraphRangeContainingCorrection->startPosition(), paragraphRangeContainingCorrection->startPosition());265 RefPtr<Range> correctionStartOffsetInParagraphAsRange = Range::create(paragraphRangeContainingCorrection->startContainer(ec)->document(), paragraphRangeContainingCorrection->startPosition(), paragraphRangeContainingCorrection->startPosition()); 266 266 if (ec) 267 267 return; … … 278 278 RefPtr<Range> rangeWithAlternative = range->cloneRange(ec); 279 279 280 int paragraphStartIndex = TextIterator::rangeLength(Range::create( m_frame.document(), m_frame.document(), 0, paragraphRangeContainingCorrection.get()->startContainer(), paragraphRangeContainingCorrection.get()->startOffset()).get());280 int paragraphStartIndex = TextIterator::rangeLength(Range::create(*m_frame.document(), m_frame.document(), 0, paragraphRangeContainingCorrection.get()->startContainer(), paragraphRangeContainingCorrection.get()->startOffset()).get()); 281 281 applyCommand(SpellingCorrectionCommand::create(rangeWithAlternative, alternative)); 282 282 // Recalculate pragraphRangeContainingCorrection, since SpellingCorrectionCommand modified the DOM, such that the original paragraphRangeContainingCorrection is no longer valid. Radar: 10305315 Bugzilla: 89526 … … 324 324 m_frame.document()->updateLayout(); 325 325 m_frame.selection().setSelection(selectionOfCorrected, FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle | FrameSelection::SpellCorrectionTriggered); 326 RefPtr<Range> range = Range::create( m_frame.document(), m_frame.selection().selection().start(), m_frame.selection().selection().end());326 RefPtr<Range> range = Range::create(*m_frame.document(), m_frame.selection().selection().start(), m_frame.selection().selection().end()); 327 327 328 328 DocumentMarkerController& markers = m_frame.document()->markers(); … … 500 500 if (!command->wasCreateLinkCommand()) 501 501 return; 502 RefPtr<Range> range = Range::create( m_frame.document(), command->startingSelection().start(), command->startingSelection().end());502 RefPtr<Range> range = Range::create(*m_frame.document(), command->startingSelection().start(), command->startingSelection().end()); 503 503 if (!range) 504 504 return; … … 592 592 return; 593 593 594 RefPtr<Range> precedingCharacterRange = Range::create( m_frame.document(), precedingCharacterPosition, endOfSelection);594 RefPtr<Range> precedingCharacterRange = Range::create(*m_frame.document(), precedingCharacterPosition, endOfSelection); 595 595 String string = plainText(precedingCharacterRange.get()); 596 596 if (string.isEmpty() || !isWhitespace(string[string.length() - 1])) … … 617 617 Position beginningOfRange = rangeWithAlternative->startPosition(); 618 618 Position precedingCharacterPosition = beginningOfRange.previous(); 619 RefPtr<Range> precedingCharacterRange = Range::create( m_frame.document(), precedingCharacterPosition, beginningOfRange);619 RefPtr<Range> precedingCharacterRange = Range::create(*m_frame.document(), precedingCharacterPosition, beginningOfRange); 620 620 621 621 Vector<DocumentMarker*> markers = markerController.markersInRange(precedingCharacterRange.get(), DocumentMarker::DeletedAutocorrection); … … 641 641 return false; 642 642 Node* node = endOfWordPosition.containerNode(); 643 RefPtr<Range> wordRange = Range::create( m_frame.document(), node, marker.startOffset(), node, marker.endOffset());643 RefPtr<Range> wordRange = Range::create(*m_frame.document(), node, marker.startOffset(), node, marker.endOffset()); 644 644 if (!wordRange) 645 645 return false; -
trunk/Source/WebCore/editing/ApplyStyleCommand.cpp
r156764 r157018 265 265 // Calculate start and end indices from the start of the tree that they're in. 266 266 Node* scope = highestAncestor(visibleStart.deepEquivalent().deprecatedNode()); 267 RefPtr<Range> startRange = Range::create( &document(), firstPositionInNode(scope), visibleStart.deepEquivalent().parentAnchoredEquivalent());268 RefPtr<Range> endRange = Range::create( &document(), firstPositionInNode(scope), visibleEnd.deepEquivalent().parentAnchoredEquivalent());267 RefPtr<Range> startRange = Range::create(document(), firstPositionInNode(scope), visibleStart.deepEquivalent().parentAnchoredEquivalent()); 268 RefPtr<Range> endRange = Range::create(document(), firstPositionInNode(scope), visibleEnd.deepEquivalent().parentAnchoredEquivalent()); 269 269 int startIndex = TextIterator::rangeLength(startRange.get(), true); 270 270 int endIndex = TextIterator::rangeLength(endRange.get(), true); … … 705 705 // e.g. When applying font-size: large on <font color="blue">hello</font>, we need to include the font element in our run 706 706 // to generate <font color="blue" size="4">hello</font> instead of <font color="blue"><font size="4">hello</font></font> 707 RefPtr<Range> range = Range::create( &startNode->document(), start, end);707 RefPtr<Range> range = Range::create(startNode->document(), start, end); 708 708 Element* editableRoot = startNode->rootEditableElement(); 709 709 if (startNode != editableRoot) { -
trunk/Source/WebCore/editing/CompositeEditCommand.cpp
r157002 r157018 534 534 DocumentMarkerController& markerController = document().markers(); 535 535 Vector<DocumentMarker> markers; 536 copyMarkers(markerController.markersInRange(Range::create( &document(), node, offset, node, offset + count).get(), DocumentMarker::AllMarkers()), markers);536 copyMarkers(markerController.markersInRange(Range::create(document(), node, offset, node, offset + count).get(), DocumentMarker::AllMarkers()), markers); 537 537 replaceTextInNode(node, offset, count, replacementText); 538 RefPtr<Range> newRange = Range::create( &document(), node, offset, node, offset + replacementText.length());538 RefPtr<Range> newRange = Range::create(document(), node, offset, node, offset + replacementText.length()); 539 539 for (size_t i = 0; i < markers.size(); ++i) 540 540 markerController.addMarker(newRange.get(), markers[i].type(), markers[i].description()); … … 1166 1166 startIndex = 0; 1167 1167 if (startInParagraph) { 1168 RefPtr<Range> startRange = Range::create( &document(), startOfParagraphToMove.deepEquivalent().parentAnchoredEquivalent(), visibleStart.deepEquivalent().parentAnchoredEquivalent());1168 RefPtr<Range> startRange = Range::create(document(), startOfParagraphToMove.deepEquivalent().parentAnchoredEquivalent(), visibleStart.deepEquivalent().parentAnchoredEquivalent()); 1169 1169 startIndex = TextIterator::rangeLength(startRange.get(), true); 1170 1170 } … … 1172 1172 endIndex = 0; 1173 1173 if (endInParagraph) { 1174 RefPtr<Range> endRange = Range::create( &document(), startOfParagraphToMove.deepEquivalent().parentAnchoredEquivalent(), visibleEnd.deepEquivalent().parentAnchoredEquivalent());1174 RefPtr<Range> endRange = Range::create(document(), startOfParagraphToMove.deepEquivalent().parentAnchoredEquivalent(), visibleEnd.deepEquivalent().parentAnchoredEquivalent()); 1175 1175 endIndex = TextIterator::rangeLength(endRange.get(), true); 1176 1176 } … … 1189 1189 Position startRangeCompliant = start.parentAnchoredEquivalent(); 1190 1190 Position endRangeCompliant = end.parentAnchoredEquivalent(); 1191 RefPtr<Range> range = Range::create( &document(), startRangeCompliant.deprecatedNode(), startRangeCompliant.deprecatedEditingOffset(), endRangeCompliant.deprecatedNode(), endRangeCompliant.deprecatedEditingOffset());1191 RefPtr<Range> range = Range::create(document(), startRangeCompliant.deprecatedNode(), startRangeCompliant.deprecatedEditingOffset(), endRangeCompliant.deprecatedNode(), endRangeCompliant.deprecatedEditingOffset()); 1192 1192 1193 1193 // FIXME: This is an inefficient way to preserve style on nodes in the paragraph to move. It … … 1235 1235 } 1236 1236 1237 RefPtr<Range> startToDestinationRange(Range::create( &document(), firstPositionInNode(document().documentElement()), destination.deepEquivalent().parentAnchoredEquivalent()));1237 RefPtr<Range> startToDestinationRange(Range::create(document(), firstPositionInNode(document().documentElement()), destination.deepEquivalent().parentAnchoredEquivalent())); 1238 1238 destinationIndex = TextIterator::rangeLength(startToDestinationRange.get(), true); 1239 1239 -
trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp
r156289 r157018 658 658 } 659 659 660 RefPtr<Range> range = Range::create( &document(), startOfParagraphToMove.deepEquivalent().parentAnchoredEquivalent(), endOfParagraphToMove.deepEquivalent().parentAnchoredEquivalent());661 RefPtr<Range> rangeToBeReplaced = Range::create( &document(), mergeDestination.deepEquivalent().parentAnchoredEquivalent(), mergeDestination.deepEquivalent().parentAnchoredEquivalent());660 RefPtr<Range> range = Range::create(document(), startOfParagraphToMove.deepEquivalent().parentAnchoredEquivalent(), endOfParagraphToMove.deepEquivalent().parentAnchoredEquivalent()); 661 RefPtr<Range> rangeToBeReplaced = Range::create(document(), mergeDestination.deepEquivalent().parentAnchoredEquivalent(), mergeDestination.deepEquivalent().parentAnchoredEquivalent()); 662 662 if (!frame().editor().client()->shouldMoveRangeAfterDelete(range.get(), rangeToBeReplaced.get())) 663 663 return; … … 761 761 return String(); 762 762 763 RefPtr<Range> rangeOfFirstCharacter = Range::create( &document(), startOfSelection.deepEquivalent(), nextPosition.deepEquivalent());763 RefPtr<Range> rangeOfFirstCharacter = Range::create(document(), startOfSelection.deepEquivalent(), nextPosition.deepEquivalent()); 764 764 Vector<DocumentMarker*> markers = document().markers().markersInRange(rangeOfFirstCharacter.get(), DocumentMarker::Autocorrected); 765 765 for (size_t i = 0; i < markers.size(); ++i) { -
trunk/Source/WebCore/editing/EditingStyle.cpp
r156760 r157018 1278 1278 end = selection.end().upstream(); 1279 1279 1280 Node* pastLast = Range::create( end.document(), position.parentAnchoredEquivalent(), end.parentAnchoredEquivalent())->pastLastNode();1280 Node* pastLast = Range::create(*end.document(), position.parentAnchoredEquivalent(), end.parentAnchoredEquivalent())->pastLastNode(); 1281 1281 for (Node* n = node; n && n != pastLast; n = NodeTraversal::next(n)) { 1282 1282 if (!n->isStyledElement()) -
trunk/Source/WebCore/editing/Editor.cpp
r156941 r157018 132 132 } 133 133 134 return Range::create( &range->ownerDocument(), startContainer, startOffset, endContainer, endOffset);134 return Range::create(range->ownerDocument(), startContainer, startOffset, endContainer, endOffset); 135 135 } 136 136 … … 488 488 return; 489 489 490 RefPtr<Range> rangeToCheck = Range::create( &document(), firstPositionInNode(nodeToCheck), lastPositionInNode(nodeToCheck));490 RefPtr<Range> rangeToCheck = Range::create(document(), firstPositionInNode(nodeToCheck), lastPositionInNode(nodeToCheck)); 491 491 m_spellChecker->requestCheckingFor(SpellCheckRequest::create(resolveTextCheckingTypeMask(TextCheckingTypeSpelling | TextCheckingTypeGrammar), TextCheckingProcessBatch, rangeToCheck, rangeToCheck)); 492 492 } … … 1631 1631 unsigned start = min(baseOffset + selectionStart, extentOffset); 1632 1632 unsigned end = min(max(start, baseOffset + selectionEnd), extentOffset); 1633 RefPtr<Range> selectedRange = Range::create( &baseNode->document(), baseNode, start, baseNode, end);1633 RefPtr<Range> selectedRange = Range::create(baseNode->document(), baseNode, start, baseNode, end); 1634 1634 m_frame.selection().setSelectedRange(selectedRange.get(), DOWNSTREAM, false); 1635 1635 } … … 2482 2482 // we would like to remove the marker from word "avant" and whitespace as well. So we need to get the continous range of 2483 2483 // of marker that contains the word in question, and remove marker on that whole range. 2484 RefPtr<Range> wordRange = Range::create( &document(), startOfFirstWord.deepEquivalent(), endOfLastWord.deepEquivalent());2484 RefPtr<Range> wordRange = Range::create(document(), startOfFirstWord.deepEquivalent(), endOfLastWord.deepEquivalent()); 2485 2485 2486 2486 Vector<DocumentMarker*> markers = document().markers().markersInRange(wordRange.get(), DocumentMarker::DictationAlternatives); … … 2541 2541 if (start >= end) 2542 2542 return 0; 2543 return Range::create( &m_compositionNode->document(), m_compositionNode.get(), start, m_compositionNode.get(), end);2543 return Range::create(m_compositionNode->document(), m_compositionNode.get(), start, m_compositionNode.get(), end); 2544 2544 } 2545 2545 -
trunk/Source/WebCore/editing/EditorCommand.cpp
r157002 r157018 271 271 Range* end = a->compareBoundaryPoints(Range::END_TO_END, b, ASSERT_NO_EXCEPTION) <= 0 ? b : a; 272 272 273 return Range::create( &a->ownerDocument(), start->startContainer(), start->startOffset(), end->endContainer(), end->endOffset());273 return Range::create(a->ownerDocument(), start->startContainer(), start->startOffset(), end->endContainer(), end->endOffset()); 274 274 } 275 275 -
trunk/Source/WebCore/editing/FormatBlockCommand.cpp
r154938 r157018 66 66 RefPtr<Node> nodeAfterInsertionPosition = outerBlock; 67 67 68 RefPtr<Range> range = Range::create( &document(), start, endOfSelection);68 RefPtr<Range> range = Range::create(document(), start, endOfSelection); 69 69 Element* refNode = enclosingBlockFlowElement(end); 70 70 Element* root = editableRootForPosition(start); -
trunk/Source/WebCore/editing/TextCheckingHelper.cpp
r155228 r157018 185 185 ASSERT(m_checkingRange); 186 186 if (!m_offsetAsRange) 187 m_offsetAsRange = Range::create( ¶graphRange()->startContainer()->document(), paragraphRange()->startPosition(), checkingRange()->startPosition());187 m_offsetAsRange = Range::create(paragraphRange()->startContainer()->document(), paragraphRange()->startPosition(), checkingRange()->startPosition()); 188 188 189 189 return m_offsetAsRange; … … 316 316 setEnd(paragraphRange.get(), endOfParagraph(m_range->startPosition())); 317 317 318 RefPtr<Range> offsetAsRange = Range::create( ¶graphRange->startContainer()->document(), paragraphRange->startPosition(), m_range->startPosition());318 RefPtr<Range> offsetAsRange = Range::create(paragraphRange->startContainer()->document(), paragraphRange->startPosition(), m_range->startPosition()); 319 319 int rangeStartOffset = TextIterator::rangeLength(offsetAsRange.get()); 320 320 int totalLengthProcessed = 0; … … 330 330 // Determine the character offset from the end of the original search range to the end of the paragraph, 331 331 // since we will want to ignore results in this area. 332 RefPtr<Range> endOffsetAsRange = Range::create( ¶graphRange->startContainer()->document(), paragraphRange->startPosition(), m_range->endPosition());332 RefPtr<Range> endOffsetAsRange = Range::create(paragraphRange->startContainer()->document(), paragraphRange->startPosition(), m_range->endPosition()); 333 333 currentEndOffset = TextIterator::rangeLength(endOffsetAsRange.get()); 334 334 lastIteration = true; … … 383 383 int spellingOffset = spellingLocation - currentStartOffset; 384 384 if (!firstIteration) { 385 RefPtr<Range> paragraphOffsetAsRange = Range::create( ¶graphRange->startContainer()->document(), m_range->startPosition(), paragraphRange->startPosition());385 RefPtr<Range> paragraphOffsetAsRange = Range::create(paragraphRange->startContainer()->document(), m_range->startPosition(), paragraphRange->startPosition()); 386 386 spellingOffset += TextIterator::rangeLength(paragraphOffsetAsRange.get()); 387 387 } … … 394 394 int grammarPhraseOffset = grammarPhraseLocation - currentStartOffset; 395 395 if (!firstIteration) { 396 RefPtr<Range> paragraphOffsetAsRange = Range::create( ¶graphRange->startContainer()->document(), m_range->startPosition(), paragraphRange->startPosition());396 RefPtr<Range> paragraphOffsetAsRange = Range::create(paragraphRange->startContainer()->document(), m_range->startPosition(), paragraphRange->startPosition()); 397 397 grammarPhraseOffset += TextIterator::rangeLength(paragraphOffsetAsRange.get()); 398 398 } -
trunk/Source/WebCore/editing/TextIterator.cpp
r156657 r157018 1066 1066 m_positionOffsetBaseNode = 0; 1067 1067 } 1068 return Range::create( &m_positionNode->document(), m_positionNode, m_positionStartOffset, m_positionNode, m_positionEndOffset);1068 return Range::create(m_positionNode->document(), m_positionNode, m_positionStartOffset, m_positionNode, m_positionEndOffset); 1069 1069 } 1070 1070 1071 1071 // otherwise, return the end of the overall range we were given 1072 1072 if (m_endContainer) 1073 return Range::create( &m_endContainer->document(), m_endContainer, m_endOffset, m_endContainer, m_endOffset);1073 return Range::create(m_endContainer->document(), m_endContainer, m_endOffset, m_endContainer, m_endOffset); 1074 1074 1075 1075 return 0; … … 1368 1368 { 1369 1369 if (m_positionNode) 1370 return Range::create( &m_positionNode->document(), m_positionNode, m_positionStartOffset, m_positionNode, m_positionEndOffset);1371 1372 return Range::create( &m_startNode->document(), m_startNode, m_startOffset, m_startNode, m_startOffset);1370 return Range::create(m_positionNode->document(), m_positionNode, m_positionStartOffset, m_positionNode, m_positionEndOffset); 1371 1372 return Range::create(m_startNode->document(), m_startNode, m_startOffset, m_startNode, m_startOffset); 1373 1373 } 1374 1374 … … 1469 1469 RefPtr<Range> end = it.range(); 1470 1470 1471 return Range::create( &start->startContainer()->document(),1471 return Range::create(start->startContainer()->document(), 1472 1472 start->startContainer(), start->startOffset(), 1473 1473 end->endContainer(), end->endOffset()); … … 2505 2505 return false; 2506 2506 2507 RefPtr<Range> testRange = Range::create( &scope->document(), scope, 0, range->startContainer(), range->startOffset());2507 RefPtr<Range> testRange = Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset()); 2508 2508 ASSERT(testRange->startContainer() == scope); 2509 2509 location = TextIterator::rangeLength(testRange.get()); -
trunk/Source/WebCore/editing/VisiblePosition.cpp
r155318 r157018 679 679 return 0; 680 680 681 return Range::create( &s.containerNode()->document(), s.containerNode(), s.offsetInContainerNode(), e.containerNode(), e.offsetInContainerNode());681 return Range::create(s.containerNode()->document(), s.containerNode(), s.offsetInContainerNode(), e.containerNode(), e.offsetInContainerNode()); 682 682 } 683 683 -
trunk/Source/WebCore/editing/VisibleSelection.cpp
r156981 r157018 131 131 Position start = m_start.parentAnchoredEquivalent(); 132 132 Position end = m_end.parentAnchoredEquivalent(); 133 return Range::create( &start.anchorNode()->document(), start, end);133 return Range::create(start.anchorNode()->document(), start, end); 134 134 } 135 135 … … 187 187 // VisibleSelections are supposed to always be valid. This constructor will ASSERT 188 188 // if a valid range could not be created, which is fine for this callsite. 189 return Range::create( &s.anchorNode()->document(), s, e);189 return Range::create(s.anchorNode()->document(), s, e); 190 190 } 191 191 … … 211 211 return 0; 212 212 213 RefPtr<Range> searchRange(Range::create( &n->document()));213 RefPtr<Range> searchRange(Range::create(n->document())); 214 214 ExceptionCode ec = 0; 215 215 -
trunk/Source/WebCore/editing/VisibleUnits.cpp
r156094 r157018 458 458 Position start = createLegacyEditingPosition(boundary, 0).parentAnchoredEquivalent(); 459 459 Position end = pos.parentAnchoredEquivalent(); 460 RefPtr<Range> searchRange = Range::create( &boundaryDocument);460 RefPtr<Range> searchRange = Range::create(boundaryDocument); 461 461 462 462 Vector<UChar, 1024> string; -
trunk/Source/WebCore/editing/htmlediting.cpp
r156987 r157018 538 538 } 539 539 540 // Create a range object with two visible positions, start and end.541 // create(PassRefPtr<Document>, const Position&, const Position&); will use deprecatedEditingOffset542 // Use this function instead of create a regular range object (avoiding editing offset).543 PassRefPtr<Range> createRange(PassRefPtr<Document> document, const VisiblePosition& start, const VisiblePosition& end, ExceptionCode& ec)544 {545 ec = 0;546 RefPtr<Range> selectedRange = Range::create(document);547 selectedRange->setStart(start.deepEquivalent().containerNode(), start.deepEquivalent().computeOffsetInContainerNode(), ec);548 if (!ec)549 selectedRange->setEnd(end.deepEquivalent().containerNode(), end.deepEquivalent().computeOffsetInContainerNode(), ec);550 return selectedRange.release();551 }552 553 // Extend rangeToExtend to include nodes that wraps range and visibly starts and ends inside or at the boudnaries of maximumRange554 // e.g. if the original range spaned "hello" in <div>hello</div>, then this function extends the range to contain div's around it.555 // Call this function before copying / moving paragraphs to contain all wrapping nodes.556 // This function stops extending the range immediately below rootNode; i.e. the extended range can contain a child node of rootNode557 // but it can never contain rootNode itself.558 PassRefPtr<Range> extendRangeToWrappingNodes(PassRefPtr<Range> range, const Range* maximumRange, const Node* rootNode)559 {560 ASSERT(range);561 ASSERT(maximumRange);562 563 Node* ancestor = range->commonAncestorContainer(IGNORE_EXCEPTION); // Find the closest common ancestor.564 Node* highestNode = 0;565 // traverse through ancestors as long as they are contained within the range, content-editable, and below rootNode (could be =0).566 while (ancestor && ancestor->rendererIsEditable() && isNodeVisiblyContainedWithin(ancestor, maximumRange) && ancestor != rootNode) {567 highestNode = ancestor;568 ancestor = ancestor->parentNode();569 }570 571 if (!highestNode)572 return range;573 574 // Create new range with the highest editable node contained within the range575 RefPtr<Range> extendedRange = Range::create(&range->ownerDocument());576 extendedRange->selectNode(highestNode, IGNORE_EXCEPTION);577 return extendedRange.release();578 }579 580 540 bool isListElement(Node *n) 581 541 { … … 1156 1116 scope = document.documentElement(); 1157 1117 1158 RefPtr<Range> range = Range::create(&document, firstPositionInNode(scope.get()), p.parentAnchoredEquivalent()); 1159 1118 RefPtr<Range> range = Range::create(document, firstPositionInNode(scope.get()), p.parentAnchoredEquivalent()); 1160 1119 return TextIterator::rangeLength(range.get(), true); 1161 1120 } … … 1165 1124 { 1166 1125 ASSERT(node); 1167 RefPtr<Range> range = Range::create( &node->document(), firstPositionInNode(node), visiblePosition.deepEquivalent().parentAnchoredEquivalent());1126 RefPtr<Range> range = Range::create(node->document(), firstPositionInNode(node), visiblePosition.deepEquivalent().parentAnchoredEquivalent()); 1168 1127 return TextIterator::rangeLength(range.get(), forSelectionPreservation); 1169 1128 } … … 1185 1144 return VisiblePosition(firstPositionInOrBeforeNode(node), DOWNSTREAM); 1186 1145 1187 RefPtr<Range> range = Range::create( &node->document());1146 RefPtr<Range> range = Range::create(node->document()); 1188 1147 range->selectNodeContents(node, IGNORE_EXCEPTION); 1189 1148 CharacterIterator it(range.get()); -
trunk/Source/WebCore/editing/htmlediting.h
r156289 r157018 195 195 196 196 // ------------------------------------------------------------------------- 197 // Range198 // -------------------------------------------------------------------------199 200 // Functions returning Range201 202 PassRefPtr<Range> createRange(PassRefPtr<Document>, const VisiblePosition& start, const VisiblePosition& end, ExceptionCode&);203 PassRefPtr<Range> extendRangeToWrappingNodes(PassRefPtr<Range> rangeToExtend, const Range* maximumRange, const Node* rootNode);204 205 // -------------------------------------------------------------------------206 197 // HTMLElement 207 198 // ------------------------------------------------------------------------- -
trunk/Source/WebCore/editing/markup.cpp
r157004 r157018 272 272 Position start = createLegacyEditingPosition(const_cast<Node*>(&node), startOffset); 273 273 Position end = createLegacyEditingPosition(const_cast<Node*>(&node), endOffset); 274 return plainText(Range::create( &node.document(), start, end).get());274 return plainText(Range::create(node.document(), start, end).get()); 275 275 } 276 276 -
trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp
r156903 r157018 434 434 435 435 if (!innerText->firstChild()) 436 return Range::create( &document(), innerText, 0, innerText, 0);436 return Range::create(document(), innerText, 0, innerText, 0); 437 437 438 438 int offset = 0; … … 458 458 return 0; 459 459 460 return Range::create( &document(), startNode, start, endNode, end);460 return Range::create(document(), startNode, start, endNode, end); 461 461 } 462 462 -
trunk/Source/WebCore/page/DOMSelection.cpp
r154877 r157018 369 369 ContainerNode* container = shadowAncestor->parentNodeGuaranteedHostFree(); 370 370 int offset = shadowAncestor->nodeIndex(); 371 return Range::create( &shadowAncestor->document(), container, offset, container, offset);371 return Range::create(shadowAncestor->document(), container, offset, container, offset); 372 372 } 373 373 -
trunk/Source/WebCore/page/EventHandler.cpp
r156948 r157018 572 572 static int textDistance(const Position& start, const Position& end) 573 573 { 574 RefPtr<Range> range = Range::create( &start.anchorNode()->document(), start, end);574 RefPtr<Range> range = Range::create(start.anchorNode()->document(), start, end); 575 575 return TextIterator::rangeLength(range.get(), true); 576 576 } -
trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp
r156450 r157018 616 616 continue; 617 617 618 RefPtr<Range> range = Range::create( &contentElement->document());618 RefPtr<Range> range = Range::create(contentElement->document()); 619 619 bool foundStartPosition = false; 620 620 bool startsAboveRegion = true; … … 657 657 range->setEndBefore(node, IGNORE_EXCEPTION); 658 658 rangeObjects.append(range->cloneRange(IGNORE_EXCEPTION)); 659 range = Range::create( &contentElement->document());659 range = Range::create(contentElement->document()); 660 660 startsAboveRegion = true; 661 661 } else -
trunk/Source/WebCore/testing/Internals.cpp
r156981 r157018 745 745 if (!marker) 746 746 return 0; 747 return Range::create( &node->document(), node, marker->startOffset(), node, marker->endOffset());747 return Range::create(node->document(), node, marker->startOffset(), node, marker->endOffset()); 748 748 } 749 749 -
trunk/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp
r156769 r157018 648 648 WebCore::Element* scope = selectionRoot ? selectionRoot : frame.document()->documentElement(); 649 649 650 RefPtr<WebCore::Range> testRange = WebCore::Range::create( &scope->document(), scope, 0, range->startContainer(), range->startOffset());650 RefPtr<WebCore::Range> testRange = WebCore::Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset()); 651 651 *start = WebCore::TextIterator::rangeLength(testRange.get()); 652 652 -
trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp
r156948 r157018 397 397 Element* scope = selectionRoot ? selectionRoot : frame.document()->documentElement(); 398 398 399 RefPtr<Range> testRange = Range::create( &scope->document(), scope, 0, range->startContainer(), range->startOffset());399 RefPtr<Range> testRange = Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset()); 400 400 ASSERT(testRange->startContainer() == scope); 401 401 *start = TextIterator::rangeLength(testRange.get()); -
trunk/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm
r156527 r157018 275 275 - (NSAttributedString *)attributedStringFrom:(DOMNode *)startNode startOffset:(int)startOffset to:(DOMNode *)endNode endOffset:(int)endOffset 276 276 { 277 return [WebHTMLConverter editingAttributedStringFromRange:Range::create( &core(startNode)->document(), core(startNode), startOffset, core(endNode), endOffset).get()];277 return [WebHTMLConverter editingAttributedStringFromRange:Range::create(core(startNode)->document(), core(startNode), startOffset, core(endNode), endOffset).get()]; 278 278 } 279 279 -
trunk/Source/WebKit/mac/WebView/WebHTMLView.mm
r156860 r157018 6032 6032 if (!attributedString) { 6033 6033 Document* coreDocument = core(document); 6034 attributedString = [WebHTMLConverter editingAttributedStringFromRange:Range::create( coreDocument, coreDocument, 0, coreDocument, coreDocument->childNodeCount()).get()];6034 attributedString = [WebHTMLConverter editingAttributedStringFromRange:Range::create(*coreDocument, coreDocument, 0, coreDocument, coreDocument->childNodeCount()).get()]; 6035 6035 } 6036 6036 return attributedString; -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRange.mm
r155228 r157018 52 52 - (id)initWithDocument:(WKDOMDocument *)document 53 53 { 54 RefPtr<WebCore::Range> range = WebCore::Range::create( WebKit::toWebCoreDocument(document));54 RefPtr<WebCore::Range> range = WebCore::Range::create(*WebKit::toWebCoreDocument(document)); 55 55 self = [self _initWithImpl:range.get()]; 56 56 if (!self)
Note: See TracChangeset
for help on using the changeset viewer.