Title: [177486] trunk/Source
Revision
177486
Author
[email protected]
Date
2014-12-17 19:06:00 -0800 (Wed, 17 Dec 2014)

Log Message

Ref-ify Range::create().
<https://webkit.org/b/139755>

Reviewed by Anders Carlsson.

Source/WebCore:

* dom/Document.cpp:
(WebCore::acceptsEditingFocus):
* dom/Element.cpp:
(WebCore::Element::innerText):
* dom/Range.cpp:
(WebCore::Range::create):
(WebCore::Range::cloneRange):
(WebCore::rangeOfContents):
* dom/Range.h:
* editing/AlternativeTextController.cpp:
(WebCore::AlternativeTextController::applyAlternativeTextToRange):
* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::replaceTextInNodePreservingMarkers):
* editing/VisibleUnits.cpp:
(WebCore::charactersAroundPosition):
* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::renderedText):
* page/FocusController.cpp:
(WebCore::relinquishesEditingFocus):

Source/WebKit/mac:

* WebView/WebHTMLRepresentation.mm:
(-[WebHTMLRepresentation attributedStringFrom:startOffset:to:endOffset:]):
* WebView/WebHTMLView.mm:
(-[WebHTMLView attributedString]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (177485 => 177486)


--- trunk/Source/WebCore/ChangeLog	2014-12-18 02:12:18 UTC (rev 177485)
+++ trunk/Source/WebCore/ChangeLog	2014-12-18 03:06:00 UTC (rev 177486)
@@ -1,3 +1,30 @@
+2014-12-17  Andreas Kling  <[email protected]>
+
+        Ref-ify Range::create().
+        <https://webkit.org/b/139755>
+
+        Reviewed by Anders Carlsson.
+
+        * dom/Document.cpp:
+        (WebCore::acceptsEditingFocus):
+        * dom/Element.cpp:
+        (WebCore::Element::innerText):
+        * dom/Range.cpp:
+        (WebCore::Range::create):
+        (WebCore::Range::cloneRange):
+        (WebCore::rangeOfContents):
+        * dom/Range.h:
+        * editing/AlternativeTextController.cpp:
+        (WebCore::AlternativeTextController::applyAlternativeTextToRange):
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::replaceTextInNodePreservingMarkers):
+        * editing/VisibleUnits.cpp:
+        (WebCore::charactersAroundPosition):
+        * editing/markup.cpp:
+        (WebCore::StyledMarkupAccumulator::renderedText):
+        * page/FocusController.cpp:
+        (WebCore::relinquishesEditingFocus):
+
 2014-12-17  Dan Bernstein  <[email protected]>
 
         <rdar://problem/19282508> WebKitLegacy is unusable due to bad dylib identifier

Modified: trunk/Source/WebCore/dom/Document.cpp (177485 => 177486)


--- trunk/Source/WebCore/dom/Document.cpp	2014-12-18 02:12:18 UTC (rev 177485)
+++ trunk/Source/WebCore/dom/Document.cpp	2014-12-18 03:06:00 UTC (rev 177486)
@@ -343,7 +343,7 @@
     if (!frame || !root)
         return false;
 
-    return frame->editor().shouldBeginEditing(rangeOfContents(*root).get());
+    return frame->editor().shouldBeginEditing(rangeOfContents(*root).ptr());
 }
 
 static bool canAccessAncestor(const SecurityOrigin* activeSecurityOrigin, Frame* targetFrame)

Modified: trunk/Source/WebCore/dom/Element.cpp (177485 => 177486)


--- trunk/Source/WebCore/dom/Element.cpp	2014-12-18 02:12:18 UTC (rev 177485)
+++ trunk/Source/WebCore/dom/Element.cpp	2014-12-18 03:06:00 UTC (rev 177486)
@@ -2100,7 +2100,7 @@
     if (!renderer())
         return textContent(true);
 
-    return plainText(rangeOfContents(*this).get());
+    return plainText(rangeOfContents(*this).ptr());
 }
 
 String Element::outerText()

Modified: trunk/Source/WebCore/dom/Range.cpp (177485 => 177486)


--- trunk/Source/WebCore/dom/Range.cpp	2014-12-18 02:12:18 UTC (rev 177485)
+++ trunk/Source/WebCore/dom/Range.cpp	2014-12-18 03:06:00 UTC (rev 177486)
@@ -72,9 +72,9 @@
     m_ownerDocument->attachRange(this);
 }
 
-PassRefPtr<Range> Range::create(Document& ownerDocument)
+Ref<Range> Range::create(Document& ownerDocument)
 {
-    return adoptRef(new Range(ownerDocument));
+    return adoptRef(*new Range(ownerDocument));
 }
 
 inline Range::Range(Document& ownerDocument, PassRefPtr<Node> startContainer, int startOffset, PassRefPtr<Node> endContainer, int endOffset)
@@ -94,26 +94,26 @@
     setEnd(endContainer, endOffset);
 }
 
-PassRefPtr<Range> Range::create(Document& ownerDocument, PassRefPtr<Node> startContainer, int startOffset, PassRefPtr<Node> endContainer, int endOffset)
+Ref<Range> Range::create(Document& ownerDocument, PassRefPtr<Node> startContainer, int startOffset, PassRefPtr<Node> endContainer, int endOffset)
 {
-    return adoptRef(new Range(ownerDocument, startContainer, startOffset, endContainer, endOffset));
+    return adoptRef(*new Range(ownerDocument, startContainer, startOffset, endContainer, endOffset));
 }
 
-PassRefPtr<Range> Range::create(Document& ownerDocument, const Position& start, const Position& end)
+Ref<Range> Range::create(Document& ownerDocument, const Position& start, const Position& end)
 {
-    return adoptRef(new Range(ownerDocument, start.containerNode(), start.computeOffsetInContainerNode(), end.containerNode(), end.computeOffsetInContainerNode()));
+    return adoptRef(*new Range(ownerDocument, start.containerNode(), start.computeOffsetInContainerNode(), end.containerNode(), end.computeOffsetInContainerNode()));
 }
 
-PassRefPtr<Range> Range::create(ScriptExecutionContext& context)
+Ref<Range> Range::create(ScriptExecutionContext& context)
 {
-    return adoptRef(new Range(downcast<Document>(context)));
+    return adoptRef(*new Range(downcast<Document>(context)));
 }
 
-PassRefPtr<Range> Range::create(Document& ownerDocument, const VisiblePosition& visibleStart, const VisiblePosition& visibleEnd)
+Ref<Range> Range::create(Document& ownerDocument, const VisiblePosition& visibleStart, const VisiblePosition& visibleEnd)
 {
     Position start = visibleStart.deepEquivalent().parentAnchoredEquivalent();
     Position end = visibleEnd.deepEquivalent().parentAnchoredEquivalent();
-    return adoptRef(new Range(ownerDocument, start.anchorNode(), start.deprecatedEditingOffset(), end.anchorNode(), end.deprecatedEditingOffset()));
+    return adoptRef(*new Range(ownerDocument, start.anchorNode(), start.deprecatedEditingOffset(), end.anchorNode(), end.deprecatedEditingOffset()));
 }
 
 Range::~Range()
@@ -1220,11 +1220,11 @@
     }
 }
 
-PassRefPtr<Range> Range::cloneRange(ExceptionCode& ec) const
+RefPtr<Range> Range::cloneRange(ExceptionCode& ec) const
 {
     if (!m_start.container()) {
         ec = INVALID_STATE_ERR;
-        return 0;
+        return nullptr;
     }
 
     return Range::create(ownerDocument(), m_start.container(), m_start.offset(), m_end.container(), m_end.offset());
@@ -2002,12 +2002,12 @@
     return false;
 }
 
-PassRefPtr<Range> rangeOfContents(Node& node)
+Ref<Range> rangeOfContents(Node& node)
 {
-    RefPtr<Range> range = Range::create(node.document());
+    Ref<Range> range = Range::create(node.document());
     int exception = 0;
     range->selectNodeContents(&node, exception);
-    return range.release();
+    return range;
 }
 
 static inline void boundaryNodeChildrenChanged(RangeBoundaryPoint& boundary, ContainerNode& container)

Modified: trunk/Source/WebCore/dom/Range.h (177485 => 177486)


--- trunk/Source/WebCore/dom/Range.h	2014-12-18 02:12:18 UTC (rev 177485)
+++ trunk/Source/WebCore/dom/Range.h	2014-12-18 03:06:00 UTC (rev 177486)
@@ -52,11 +52,11 @@
 
 class Range : public RefCounted<Range> {
 public:
-    WEBCORE_EXPORT static PassRefPtr<Range> create(Document&);
-    WEBCORE_EXPORT static PassRefPtr<Range> create(Document&, PassRefPtr<Node> startContainer, int startOffset, PassRefPtr<Node> endContainer, int endOffset);
-    WEBCORE_EXPORT static PassRefPtr<Range> create(Document&, const Position&, const Position&);
-    WEBCORE_EXPORT static PassRefPtr<Range> create(ScriptExecutionContext&);
-    WEBCORE_EXPORT static PassRefPtr<Range> create(Document&, const VisiblePosition&, const VisiblePosition&);
+    WEBCORE_EXPORT static Ref<Range> create(Document&);
+    WEBCORE_EXPORT static Ref<Range> create(Document&, PassRefPtr<Node> startContainer, int startOffset, PassRefPtr<Node> endContainer, int endOffset);
+    WEBCORE_EXPORT static Ref<Range> create(Document&, const Position&, const Position&);
+    WEBCORE_EXPORT static Ref<Range> create(ScriptExecutionContext&);
+    WEBCORE_EXPORT static Ref<Range> create(Document&, const VisiblePosition&, const VisiblePosition&);
     WEBCORE_EXPORT ~Range();
 
     Document& ownerDocument() const { return const_cast<Document&>(m_ownerDocument.get()); }
@@ -99,7 +99,7 @@
     PassRefPtr<DocumentFragment> createContextualFragment(const String& html, ExceptionCode&);
 
     void detach(ExceptionCode&);
-    WEBCORE_EXPORT PassRefPtr<Range> cloneRange(ExceptionCode&) const;
+    WEBCORE_EXPORT RefPtr<Range> cloneRange(ExceptionCode&) const;
 
     WEBCORE_EXPORT void setStartAfter(Node*, ExceptionCode& = ASSERT_NO_EXCEPTION);
     WEBCORE_EXPORT void setEndBefore(Node*, ExceptionCode& = ASSERT_NO_EXCEPTION);
@@ -183,7 +183,7 @@
     RangeBoundaryPoint m_end;
 };
 
-PassRefPtr<Range> rangeOfContents(Node&);
+Ref<Range> rangeOfContents(Node&);
 
 WEBCORE_EXPORT bool areRangesEqual(const Range*, const Range*);
 bool rangesOverlap(const Range*, const Range*);

Modified: trunk/Source/WebCore/editing/AlternativeTextController.cpp (177485 => 177486)


--- trunk/Source/WebCore/editing/AlternativeTextController.cpp	2014-12-18 02:12:18 UTC (rev 177485)
+++ trunk/Source/WebCore/editing/AlternativeTextController.cpp	2014-12-18 03:06:00 UTC (rev 177486)
@@ -273,7 +273,7 @@
     RefPtr<Range> rangeWithAlternative = range->cloneRange(ec);
 
     ContainerNode& rootNode = paragraphRangeContainingCorrection.get()->startContainer()->treeScope().rootNode();
-    int paragraphStartIndex = TextIterator::rangeLength(Range::create(rootNode.document(), &rootNode, 0, paragraphRangeContainingCorrection.get()->startContainer(), paragraphRangeContainingCorrection.get()->startOffset()).get());
+    int paragraphStartIndex = TextIterator::rangeLength(Range::create(rootNode.document(), &rootNode, 0, paragraphRangeContainingCorrection->startContainer(), paragraphRangeContainingCorrection->startOffset()).ptr());
     applyCommand(SpellingCorrectionCommand::create(rangeWithAlternative, alternative));
     // Recalculate pragraphRangeContainingCorrection, since SpellingCorrectionCommand modified the DOM, such that the original paragraphRangeContainingCorrection is no longer valid. Radar: 10305315 Bugzilla: 89526
     paragraphRangeContainingCorrection = TextIterator::rangeFromLocationAndLength(&rootNode, paragraphStartIndex, correctionStartOffsetInParagraph + alternative.length());

Modified: trunk/Source/WebCore/editing/CompositeEditCommand.cpp (177485 => 177486)


--- trunk/Source/WebCore/editing/CompositeEditCommand.cpp	2014-12-18 02:12:18 UTC (rev 177485)
+++ trunk/Source/WebCore/editing/CompositeEditCommand.cpp	2014-12-18 03:06:00 UTC (rev 177486)
@@ -569,7 +569,7 @@
     RefPtr<Text> node(prpNode);
     DocumentMarkerController& markerController = document().markers();
     Vector<RenderedDocumentMarker> markers;
-    copyMarkers(markerController.markersInRange(Range::create(document(), node, offset, node, offset + count).get(), DocumentMarker::AllMarkers()), markers);
+    copyMarkers(markerController.markersInRange(Range::create(document(), node, offset, node, offset + count).ptr(), DocumentMarker::AllMarkers()), markers);
     replaceTextInNode(node, offset, count, replacementText);
     RefPtr<Range> newRange = Range::create(document(), node, offset, node, offset + replacementText.length());
     for (const auto& marker : markers)

Modified: trunk/Source/WebCore/editing/VisibleUnits.cpp (177485 => 177486)


--- trunk/Source/WebCore/editing/VisibleUnits.cpp	2014-12-18 02:12:18 UTC (rev 177485)
+++ trunk/Source/WebCore/editing/VisibleUnits.cpp	2014-12-18 03:06:00 UTC (rev 177486)
@@ -1830,7 +1830,7 @@
     }
 
     if (startPosition != endPosition) {
-        String characterString = plainText(Range::create(position.deepEquivalent().anchorNode()->document(), startPosition, endPosition).get()).replace(noBreakSpace, ' ');
+        String characterString = plainText(Range::create(position.deepEquivalent().anchorNode()->document(), startPosition, endPosition).ptr()).replace(noBreakSpace, ' ');
         for (int i = characterString.length() - 1, index = 0; i >= 0 && index < maxCharacters; --i) {
             if (!index && nextPosition.isNull())
                 index++;

Modified: trunk/Source/WebCore/editing/markup.cpp (177485 => 177486)


--- trunk/Source/WebCore/editing/markup.cpp	2014-12-18 02:12:18 UTC (rev 177485)
+++ trunk/Source/WebCore/editing/markup.cpp	2014-12-18 03:06:00 UTC (rev 177486)
@@ -276,7 +276,7 @@
 
     Position start = createLegacyEditingPosition(const_cast<Node*>(&node), startOffset);
     Position end = createLegacyEditingPosition(const_cast<Node*>(&node), endOffset);
-    return plainText(Range::create(node.document(), start, end).get(), behavior);
+    return plainText(Range::create(node.document(), start, end).ptr(), behavior);
 }
 
 String StyledMarkupAccumulator::stringValueForRange(const Node& node, const Range* range)

Modified: trunk/Source/WebCore/page/FocusController.cpp (177485 => 177486)


--- trunk/Source/WebCore/page/FocusController.cpp	2014-12-18 02:12:18 UTC (rev 177485)
+++ trunk/Source/WebCore/page/FocusController.cpp	2014-12-18 03:06:00 UTC (rev 177486)
@@ -544,7 +544,7 @@
     if (!frame || !root)
         return false;
 
-    return frame->editor().shouldEndEditing(rangeOfContents(*root).get());
+    return frame->editor().shouldEndEditing(rangeOfContents(*root).ptr());
 }
 
 static void clearSelectionIfNeeded(Frame* oldFocusedFrame, Frame* newFocusedFrame, Node* newFocusedNode)

Modified: trunk/Source/WebKit/mac/ChangeLog (177485 => 177486)


--- trunk/Source/WebKit/mac/ChangeLog	2014-12-18 02:12:18 UTC (rev 177485)
+++ trunk/Source/WebKit/mac/ChangeLog	2014-12-18 03:06:00 UTC (rev 177486)
@@ -1,3 +1,15 @@
+2014-12-17  Andreas Kling  <[email protected]>
+
+        Ref-ify Range::create().
+        <https://webkit.org/b/139755>
+
+        Reviewed by Anders Carlsson.
+
+        * WebView/WebHTMLRepresentation.mm:
+        (-[WebHTMLRepresentation attributedStringFrom:startOffset:to:endOffset:]):
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView attributedString]):
+
 2014-12-17  Anders Carlsson  <[email protected]>
 
         Unify -[WebResource description]

Modified: trunk/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm (177485 => 177486)


--- trunk/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm	2014-12-18 02:12:18 UTC (rev 177485)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm	2014-12-18 03:06:00 UTC (rev 177486)
@@ -277,7 +277,7 @@
 
 - (NSAttributedString *)attributedStringFrom:(DOMNode *)startNode startOffset:(int)startOffset to:(DOMNode *)endNode endOffset:(int)endOffset
 {
-    return editingAttributedStringFromRange(*Range::create(core(startNode)->document(), core(startNode), startOffset, core(endNode), endOffset));
+    return editingAttributedStringFromRange(Range::create(core(startNode)->document(), core(startNode), startOffset, core(endNode), endOffset));
 }
 #endif
 

Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (177485 => 177486)


--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm	2014-12-18 02:12:18 UTC (rev 177485)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm	2014-12-18 03:06:00 UTC (rev 177486)
@@ -6717,7 +6717,7 @@
     NSAttributedString *attributedString = [self _attributeStringFromDOMRange:[document _documentRange]];
     if (!attributedString) {
         Document* coreDocument = core(document);
-        attributedString = editingAttributedStringFromRange(*Range::create(*coreDocument, coreDocument, 0, coreDocument, coreDocument->countChildNodes()));
+        attributedString = editingAttributedStringFromRange(Range::create(*coreDocument, coreDocument, 0, coreDocument, coreDocument->countChildNodes()));
     }
     return attributedString;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to