Title: [159891] trunk/Source/WebKit2
Revision
159891
Author
[email protected]
Date
2013-11-30 18:25:39 -0800 (Sat, 30 Nov 2013)

Log Message

[CTTE] The WebPageProxy's WebBackForwardList is never null so it should be stored in a Ref
https://bugs.webkit.org/show_bug.cgi?id=125035

Reviewed by Dan Bernstein.

* UIProcess/API/C/WKPage.cpp:
(WKPageGetBackForwardList):
* UIProcess/API/Cocoa/WKBrowsingContextController.mm:
(-[WKBrowsingContextController backForwardList]): Remove null check.
* UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::WebBackForwardList):
(WebKit::WebBackForwardList::currentItem): Constify.
(WebKit::WebBackForwardList::backItem): Constify.
(WebKit::WebBackForwardList::forwardItem): Constify.
(WebKit::WebBackForwardList::itemAtIndex): Constify.
* UIProcess/WebBackForwardList.h:
(WebKit::WebBackForwardList::create):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::backForwardList):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (159890 => 159891)


--- trunk/Source/WebKit2/ChangeLog	2013-11-30 20:15:46 UTC (rev 159890)
+++ trunk/Source/WebKit2/ChangeLog	2013-12-01 02:25:39 UTC (rev 159891)
@@ -1,3 +1,27 @@
+2013-11-30  Sam Weinig  <[email protected]>
+
+        [CTTE] The WebPageProxy's WebBackForwardList is never null so it should be stored in a Ref
+        https://bugs.webkit.org/show_bug.cgi?id=125035
+
+        Reviewed by Dan Bernstein.
+
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageGetBackForwardList):
+        * UIProcess/API/Cocoa/WKBrowsingContextController.mm:
+        (-[WKBrowsingContextController backForwardList]): Remove null check.
+        * UIProcess/WebBackForwardList.cpp:
+        (WebKit::WebBackForwardList::WebBackForwardList):
+        (WebKit::WebBackForwardList::currentItem): Constify.
+        (WebKit::WebBackForwardList::backItem): Constify.
+        (WebKit::WebBackForwardList::forwardItem): Constify.
+        (WebKit::WebBackForwardList::itemAtIndex): Constify.
+        * UIProcess/WebBackForwardList.h:
+        (WebKit::WebBackForwardList::create):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy):
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::backForwardList):
+
 2013-11-30  Zan Dobersek  <[email protected]>
 
         Unreviewed GTK build fix after r159889.

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (159890 => 159891)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2013-11-30 20:15:46 UTC (rev 159890)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2013-12-01 02:25:39 UTC (rev 159891)
@@ -205,7 +205,7 @@
 
 WKBackForwardListRef WKPageGetBackForwardList(WKPageRef pageRef)
 {
-    return toAPI(toImpl(pageRef)->backForwardList());
+    return toAPI(&toImpl(pageRef)->backForwardList());
 }
 
 bool WKPageWillHandleHorizontalScrollEvents(WKPageRef pageRef)

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm (159890 => 159891)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm	2013-11-30 20:15:46 UTC (rev 159890)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm	2013-12-01 02:25:39 UTC (rev 159891)
@@ -323,11 +323,7 @@
 
 - (WKBackForwardList *)backForwardList
 {
-    WebBackForwardList* list = _page->backForwardList();
-    if (!list)
-        return nil;
-
-    return wrapper(*list);
+    return wrapper(_page->backForwardList());
 }
 
 #pragma mark Active Load Introspection

Modified: trunk/Source/WebKit2/UIProcess/WebBackForwardList.cpp (159890 => 159891)


--- trunk/Source/WebKit2/UIProcess/WebBackForwardList.cpp	2013-11-30 20:15:46 UTC (rev 159890)
+++ trunk/Source/WebKit2/UIProcess/WebBackForwardList.cpp	2013-12-01 02:25:39 UTC (rev 159891)
@@ -33,13 +33,12 @@
 
 static const unsigned DefaultCapacity = 100;
 
-WebBackForwardList::WebBackForwardList(WebPageProxy* page)
-    : m_page(page)
+WebBackForwardList::WebBackForwardList(WebPageProxy& page)
+    : m_page(&page)
     , m_hasCurrentIndex(false)
     , m_currentIndex(0)
     , m_capacity(DefaultCapacity)
 {
-    ASSERT(m_page);
 }
 
 WebBackForwardList::~WebBackForwardList()
@@ -149,40 +148,40 @@
     }
 }
 
-WebBackForwardListItem* WebBackForwardList::currentItem()
+WebBackForwardListItem* WebBackForwardList::currentItem() const
 {
     ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size());
 
-    return m_page && m_hasCurrentIndex ? m_entries[m_currentIndex].get() : 0;
+    return m_page && m_hasCurrentIndex ? m_entries[m_currentIndex].get() : nullptr;
 }
 
-WebBackForwardListItem* WebBackForwardList::backItem()
+WebBackForwardListItem* WebBackForwardList::backItem() const
 {
     ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size());
 
-    return m_page && m_hasCurrentIndex && m_currentIndex ? m_entries[m_currentIndex - 1].get() : 0;
+    return m_page && m_hasCurrentIndex && m_currentIndex ? m_entries[m_currentIndex - 1].get() : nullptr;
 }
 
-WebBackForwardListItem* WebBackForwardList::forwardItem()
+WebBackForwardListItem* WebBackForwardList::forwardItem() const
 {
     ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size());
 
-    return m_page && m_hasCurrentIndex && m_entries.size() && m_currentIndex < m_entries.size() - 1 ? m_entries[m_currentIndex + 1].get() : 0;
+    return m_page && m_hasCurrentIndex && m_entries.size() && m_currentIndex < m_entries.size() - 1 ? m_entries[m_currentIndex + 1].get() : nullptr;
 }
 
-WebBackForwardListItem* WebBackForwardList::itemAtIndex(int index)
+WebBackForwardListItem* WebBackForwardList::itemAtIndex(int index) const
 {
     ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size());
 
     if (!m_hasCurrentIndex || !m_page)
-        return 0;
+        return nullptr;
     
     // Do range checks without doing math on index to avoid overflow.
     if (index < -backListCount())
-        return 0;
+        return nullptr;
     
     if (index > forwardListCount())
-        return 0;
+        return nullptr;
         
     return m_entries[index + m_currentIndex].get();
 }

Modified: trunk/Source/WebKit2/UIProcess/WebBackForwardList.h (159890 => 159891)


--- trunk/Source/WebKit2/UIProcess/WebBackForwardList.h	2013-11-30 20:15:46 UTC (rev 159890)
+++ trunk/Source/WebKit2/UIProcess/WebBackForwardList.h	2013-12-01 02:25:39 UTC (rev 159891)
@@ -29,7 +29,7 @@
 #include "APIObject.h"
 #include "WebBackForwardListItem.h"
 #include "WebPageProxy.h"
-#include <wtf/PassRefPtr.h>
+#include <wtf/PassRef.h>
 #include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
 #if USE(CF)
@@ -46,9 +46,9 @@
 
 class WebBackForwardList : public API::TypedObject<API::Object::Type::BackForwardList> {
 public:
-    static PassRefPtr<WebBackForwardList> create(WebPageProxy* page)
+    static PassRef<WebBackForwardList> create(WebPageProxy& page)
     {
-        return adoptRef(new WebBackForwardList(page));
+        return adoptRef(*new WebBackForwardList(page));
     }
     void pageClosed();
 
@@ -58,10 +58,10 @@
     void goToItem(WebBackForwardListItem*);
     void clear();
 
-    WebBackForwardListItem* currentItem();
-    WebBackForwardListItem* backItem();
-    WebBackForwardListItem* forwardItem();
-    WebBackForwardListItem* itemAtIndex(int);
+    WebBackForwardListItem* currentItem() const;
+    WebBackForwardListItem* backItem() const;
+    WebBackForwardListItem* forwardItem() const;
+    WebBackForwardListItem* itemAtIndex(int) const;
     
     const BackForwardListItemVector& entries() const { return m_entries; }
 
@@ -80,7 +80,7 @@
 #endif
 
 private:
-    explicit WebBackForwardList(WebPageProxy*);
+    explicit WebBackForwardList(WebPageProxy&);
 
     WebPageProxy* m_page;
     BackForwardListItemVector m_entries;

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (159890 => 159891)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2013-11-30 20:15:46 UTC (rev 159890)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2013-12-01 02:25:39 UTC (rev 159891)
@@ -237,7 +237,7 @@
     , m_notificationPermissionRequestManager(*this)
     , m_estimatedProgress(0)
     , m_viewState(ViewState::NoFlags)
-    , m_backForwardList(WebBackForwardList::create(this))
+    , m_backForwardList(WebBackForwardList::create(*this))
     , m_loadStateAtProcessExit(FrameLoadState::State::Finished)
     , m_temporarilyClosedComposition(false)
     , m_textZoomFactor(1)

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (159890 => 159891)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2013-11-30 20:15:46 UTC (rev 159890)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2013-12-01 02:25:39 UTC (rev 159891)
@@ -333,7 +333,7 @@
 
     DrawingAreaProxy* drawingArea() const { return m_drawingArea.get(); }
 
-    WebBackForwardList* backForwardList() const { return m_backForwardList.get(); }
+    WebBackForwardList& backForwardList() { return m_backForwardList.get(); }
 
 #if ENABLE(INSPECTOR)
     WebInspectorProxy* inspector();
@@ -1212,7 +1212,7 @@
 
     bool m_canGoBack;
     bool m_canGoForward;
-    RefPtr<WebBackForwardList> m_backForwardList;
+    Ref<WebBackForwardList> m_backForwardList;
     
     bool m_maintainsInactiveSelection;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to