Purge PassRefPtr from Page.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Jan 2015 21:48:31 +0000 (21:48 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Jan 2015 21:48:31 +0000 (21:48 +0000)
<https://webkit.org/b/140089>

Reviewed by Anders Carlsson.

Source/WebCore:

Use Ref or RefPtr instead of PassRefPtr as appropriate in WebCore::Page.

* page/Page.cpp:
(WebCore::Page::rangeOfString):
(WebCore::Page::setSessionStorage):
* page/Page.h:
* page/mac/PageMac.cpp:
(WebCore::Page::addSchedulePair):
(WebCore::Page::removeSchedulePair):

Source/WTF:

Make SchedulePair::create() return Ref since it never fails.

* wtf/SchedulePair.h:
(WTF::SchedulePair::create):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@177929 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/SchedulePair.h
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/page/mac/PageMac.cpp

index 7982ca4..149c8ed 100644 (file)
@@ -1,3 +1,15 @@
+2015-01-05  Andreas Kling  <akling@apple.com>
+
+        Purge PassRefPtr from Page.
+        <https://webkit.org/b/140089>
+
+        Reviewed by Anders Carlsson.
+
+        Make SchedulePair::create() return Ref since it never fails.
+
+        * wtf/SchedulePair.h:
+        (WTF::SchedulePair::create):
+
 2015-01-01  Darin Adler  <darin@apple.com>
 
         Rework code that hides characters in password fields to streamline a little
index de8897e..95e0f85 100644 (file)
@@ -43,10 +43,10 @@ namespace WTF {
 
 class SchedulePair : public RefCounted<SchedulePair> {
 public:
-    static PassRefPtr<SchedulePair> create(CFRunLoopRef runLoop, CFStringRef mode) { return adoptRef(new SchedulePair(runLoop, mode)); }
+    static Ref<SchedulePair> create(CFRunLoopRef runLoop, CFStringRef mode) { return adoptRef(*new SchedulePair(runLoop, mode)); }
 
 #if USE(FOUNDATION) && !USE(CFNETWORK)
-    static PassRefPtr<SchedulePair> create(NSRunLoop* runLoop, CFStringRef mode) { return adoptRef(new SchedulePair(runLoop, mode)); }
+    static Ref<SchedulePair> create(NSRunLoop* runLoop, CFStringRef mode) { return adoptRef(*new SchedulePair(runLoop, mode)); }
     NSRunLoop* nsRunLoop() const { return m_nsRunLoop.get(); }
 #endif
 
index 9d50f0f..6733e76 100644 (file)
@@ -1,3 +1,20 @@
+2015-01-05  Andreas Kling  <akling@apple.com>
+
+        Purge PassRefPtr from Page.
+        <https://webkit.org/b/140089>
+
+        Reviewed by Anders Carlsson.
+
+        Use Ref or RefPtr instead of PassRefPtr as appropriate in WebCore::Page.
+
+        * page/Page.cpp:
+        (WebCore::Page::rangeOfString):
+        (WebCore::Page::setSessionStorage):
+        * page/Page.h:
+        * page/mac/PageMac.cpp:
+        (WebCore::Page::addSchedulePair):
+        (WebCore::Page::removeSchedulePair):
+
 2015-01-05  Chris Dumez  <cdumez@apple.com>
 
         Regression(r163928): Animated images are not resumed on window resizing
index 3ae7e4b..18f24d7 100644 (file)
@@ -1154,11 +1154,11 @@ __ZN7WebCore4Page13setIsInWindowEb
 __ZN7WebCore4Page13setPaginationERKNS_10PaginationE
 __ZN7WebCore4Page14setIsPrerenderEv
 __ZN7WebCore4Page14setMediaVolumeEf
-__ZN7WebCore4Page15addSchedulePairEN3WTF10PassRefPtrINS1_12SchedulePairEEE
+__ZN7WebCore4Page15addSchedulePairEON3WTF3RefINS1_12SchedulePairEEE
 __ZN7WebCore4Page16countFindMatchesERKN3WTF6StringEhj
 __ZN7WebCore4Page16setCanStartMediaEb
 __ZN7WebCore4Page16setDefersLoadingEb
-__ZN7WebCore4Page18removeSchedulePairEN3WTF10PassRefPtrINS1_12SchedulePairEEE
+__ZN7WebCore4Page18removeSchedulePairEON3WTF3RefINS1_12SchedulePairEEE
 __ZN7WebCore4Page18setPageScaleFactorEfRKNS_8IntPointEb
 __ZN7WebCore4Page18setTopContentInsetEf
 __ZN7WebCore4Page19addLayoutMilestonesEj
index 40520aa..0b5a555 100644 (file)
@@ -635,20 +635,20 @@ void Page::findStringMatchingRanges(const String& target, FindOptions options, i
     }
 }
 
-PassRefPtr<Range> Page::rangeOfString(const String& target, Range* referenceRange, FindOptions options)
+RefPtr<Range> Page::rangeOfString(const String& target, Range* referenceRange, FindOptions options)
 {
     if (target.isEmpty())
-        return 0;
+        return nullptr;
 
     if (referenceRange && referenceRange->ownerDocument().page() != this)
-        return 0;
+        return nullptr;
 
     bool shouldWrap = options & WrapAround;
     Frame* frame = referenceRange ? referenceRange->ownerDocument().frame() : &mainFrame();
     Frame* startFrame = frame;
     do {
         if (RefPtr<Range> resultRange = frame->editor().rangeOfString(target, frame == startFrame ? referenceRange : 0, options & ~WrapAround))
-            return resultRange.release();
+            return resultRange;
 
         frame = incrementFrame(frame, !(options & Backwards), shouldWrap);
     } while (frame && frame != startFrame);
@@ -657,10 +657,10 @@ PassRefPtr<Range> Page::rangeOfString(const String& target, Range* referenceRang
     // We cheat a bit and just search again with wrap on.
     if (shouldWrap && referenceRange) {
         if (RefPtr<Range> resultRange = startFrame->editor().rangeOfString(target, referenceRange, options | WrapAround | StartInSelection))
-            return resultRange.release();
+            return resultRange;
     }
 
-    return 0;
+    return nullptr;
 }
 
 unsigned Page::findMatchesForText(const String& target, FindOptions options, unsigned maxMatchCount, ShouldHighlightMatches shouldHighlightMatches, ShouldMarkMatches shouldMarkMatches)
@@ -1096,9 +1096,9 @@ StorageNamespace* Page::sessionStorage(bool optionalCreate)
     return m_sessionStorage.get();
 }
 
-void Page::setSessionStorage(PassRefPtr<StorageNamespace> newStorage)
+void Page::setSessionStorage(RefPtr<StorageNamespace>&& newStorage)
 {
-    m_sessionStorage = newStorage;
+    m_sessionStorage = WTF::move(newStorage);
 }
 
 bool Page::hasCustomHTMLTokenizerTimeDelay() const
index 2797758..ee25edd 100644 (file)
@@ -218,7 +218,7 @@ public:
 
     WEBCORE_EXPORT bool findString(const String&, FindOptions);
 
-    WEBCORE_EXPORT PassRefPtr<Range> rangeOfString(const String&, Range*, FindOptions);
+    WEBCORE_EXPORT RefPtr<Range> rangeOfString(const String&, Range*, FindOptions);
 
     WEBCORE_EXPORT unsigned countFindMatches(const String&, FindOptions, unsigned maxMatchCount);
     WEBCORE_EXPORT unsigned markAllMatchesForText(const String&, FindOptions, bool shouldHighlight, unsigned maxMatchCount);
@@ -233,8 +233,8 @@ public:
     enum { NoMatchAfterUserSelection = -1 };
     WEBCORE_EXPORT void findStringMatchingRanges(const String&, FindOptions, int maxCount, Vector<RefPtr<Range>>&, int& indexForSelection);
 #if PLATFORM(COCOA)
-    WEBCORE_EXPORT void addSchedulePair(PassRefPtr<SchedulePair>);
-    WEBCORE_EXPORT void removeSchedulePair(PassRefPtr<SchedulePair>);
+    WEBCORE_EXPORT void addSchedulePair(Ref<SchedulePair>&&);
+    WEBCORE_EXPORT void removeSchedulePair(Ref<SchedulePair>&&);
     SchedulePairHashSet* scheduledRunLoopPairs() { return m_scheduledRunLoopPairs.get(); }
 
     std::unique_ptr<SchedulePairHashSet> m_scheduledRunLoopPairs;
@@ -323,7 +323,7 @@ public:
     WEBCORE_EXPORT void invalidateStylesForLink(LinkHash);
 
     StorageNamespace* sessionStorage(bool optionalCreate = true);
-    void setSessionStorage(PassRefPtr<StorageNamespace>);
+    void setSessionStorage(RefPtr<StorageNamespace>&&);
 
     bool hasCustomHTMLTokenizerTimeDelay() const;
     double customHTMLTokenizerTimeDelay() const;
index a2f548c..eb7caed 100644 (file)
 
 namespace WebCore {
 
-void Page::addSchedulePair(PassRefPtr<SchedulePair> prpPair)
+void Page::addSchedulePair(Ref<SchedulePair>&& pair)
 {
-    RefPtr<SchedulePair> pair = prpPair;
-
     if (!m_scheduledRunLoopPairs)
         m_scheduledRunLoopPairs = std::make_unique<SchedulePairHashSet>();
-    m_scheduledRunLoopPairs->add(pair);
+    m_scheduledRunLoopPairs->add(pair.ptr());
 
 #if !PLATFORM(IOS)
     for (Frame* frame = m_mainFrame.get(); frame; frame = frame->tree().traverseNext()) {
         if (DocumentLoader* documentLoader = frame->loader().documentLoader())
-            documentLoader->schedule(*pair);
+            documentLoader->schedule(pair);
         if (DocumentLoader* documentLoader = frame->loader().provisionalDocumentLoader())
-            documentLoader->schedule(*pair);
+            documentLoader->schedule(pair);
     }
 #endif
 
     // FIXME: make SharedTimerMac use these SchedulePairs.
 }
 
-void Page::removeSchedulePair(PassRefPtr<SchedulePair> prpPair)
+void Page::removeSchedulePair(Ref<SchedulePair>&& pair)
 {
     ASSERT(m_scheduledRunLoopPairs);
     if (!m_scheduledRunLoopPairs)
         return;
 
-    RefPtr<SchedulePair> pair = prpPair;
-    m_scheduledRunLoopPairs->remove(pair);
+    m_scheduledRunLoopPairs->remove(pair.ptr());
 
 #if !PLATFORM(IOS)
     for (Frame* frame = m_mainFrame.get(); frame; frame = frame->tree().traverseNext()) {
         if (DocumentLoader* documentLoader = frame->loader().documentLoader())
-            documentLoader->unschedule(*pair);
+            documentLoader->unschedule(pair);
         if (DocumentLoader* documentLoader = frame->loader().provisionalDocumentLoader())
-            documentLoader->unschedule(*pair);
+            documentLoader->unschedule(pair);
     }
 #endif
 }