HistoryItem* BackForwardList::itemAtIndex(int index) { // Do range checks without doing math on index to avoid overflow. if (index < -(int)m_current) return 0; if (index > forwardListCount()) return 0; return m_entries[index + m_current].get(); }
WebBackForwardListItem* WebBackForwardList::itemAtIndex(int index) { // Do range checks without doing math on index to avoid overflow. if (index < -static_cast<int>(m_current)) return 0; if (index > forwardListCount()) return 0; return m_entries[index + m_current].get(); }
PassRefPtr<ImmutableArray> WebBackForwardList::forwardListAsImmutableArrayWithLimit(unsigned limit) { unsigned size = std::min(static_cast<unsigned>(forwardListCount()), limit); if (!size) return ImmutableArray::create(); Vector<RefPtr<APIObject> > vector; vector.reserveInitialCapacity(size); unsigned last = m_current + size; ASSERT(last < m_entries.size()); for (unsigned i = m_current + 1; i <= last; ++i) vector.uncheckedAppend(m_entries[i].get()); return ImmutableArray::adopt(vector); }
WebBackForwardListItem* WebBackForwardList::itemAtIndex(int index) { ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size()); if (m_current == NoCurrentItemIndex) return 0; // Do range checks without doing math on index to avoid overflow. if (index < -backListCount()) return 0; if (index > forwardListCount()) return 0; return m_entries[index + m_current].get(); }
WebBackForwardListItem* WebBackForwardList::itemAtIndex(int index) const { ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size()); if (!m_hasCurrentIndex || !m_page) return nullptr; // Do range checks without doing math on index to avoid overflow. if (index < -backListCount()) return nullptr; if (index > forwardListCount()) return nullptr; return m_entries[index + m_currentIndex].get(); }
PassRefPtr<API::Array> WebBackForwardList::forwardListAsAPIArrayWithLimit(unsigned limit) const { ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size()); if (!m_page || !m_hasCurrentIndex) return API::Array::create(); unsigned size = std::min(static_cast<unsigned>(forwardListCount()), limit); if (!size) return API::Array::create(); Vector<RefPtr<API::Object>> vector; vector.reserveInitialCapacity(size); unsigned last = m_currentIndex + size; ASSERT(last < m_entries.size()); for (unsigned i = m_currentIndex + 1; i <= last; ++i) { ASSERT(m_entries[i]); vector.uncheckedAppend(m_entries[i].get()); } return API::Array::create(std::move(vector)); }
bool ReadingHistory::canGoForward() const { return forwardListCount() > 0; }
PassRefPtr<API::Array> WebBackForwardList::forwardList() const { return forwardListAsAPIArrayWithLimit(forwardListCount()); }