Commit a9c75620 authored by weinig@apple.com's avatar weinig@apple.com
Browse files

[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):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159891 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 527a5f65
2013-11-30 Sam Weinig <sam@webkit.org>
[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 <zdobersek@igalia.com>
Unreviewed GTK build fix after r159889.
......
......@@ -205,7 +205,7 @@ void WKPageTryRestoreScrollPosition(WKPageRef pageRef)
WKBackForwardListRef WKPageGetBackForwardList(WKPageRef pageRef)
{
return toAPI(toImpl(pageRef)->backForwardList());
return toAPI(&toImpl(pageRef)->backForwardList());
}
bool WKPageWillHandleHorizontalScrollEvents(WKPageRef pageRef)
......
......@@ -323,11 +323,7 @@ static void releaseNSData(unsigned char*, const void* data)
- (WKBackForwardList *)backForwardList
{
WebBackForwardList* list = _page->backForwardList();
if (!list)
return nil;
return wrapper(*list);
return wrapper(_page->backForwardList());
}
#pragma mark Active Load Introspection
......
......@@ -33,13 +33,12 @@ namespace WebKit {
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 @@ void WebBackForwardList::goToItem(WebBackForwardListItem* item)
}
}
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();
}
......
......@@ -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 @@ namespace WebKit {
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 @@ public:
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 @@ public:
#endif
private:
explicit WebBackForwardList(WebPageProxy*);
explicit WebBackForwardList(WebPageProxy&);
WebPageProxy* m_page;
BackForwardListItemVector m_entries;
......
......@@ -237,7 +237,7 @@ WebPageProxy::WebPageProxy(PageClient& pageClient, PassRefPtr<WebProcessProxy> p
, 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)
......
......@@ -333,7 +333,7 @@ public:
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 @@ private:
bool m_canGoBack;
bool m_canGoForward;
RefPtr<WebBackForwardList> m_backForwardList;
Ref<WebBackForwardList> m_backForwardList;
bool m_maintainsInactiveSelection;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment