Home | History | Annotate | Download | only in History
      1 /*
      2  * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  *
      8  * 1.  Redistributions of source code must retain the above copyright
      9  *     notice, this list of conditions and the following disclaimer.
     10  * 2.  Redistributions in binary form must reproduce the above copyright
     11  *     notice, this list of conditions and the following disclaimer in the
     12  *     documentation and/or other materials provided with the distribution.
     13  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
     14  *     its contributors may be used to endorse or promote products derived
     15  *     from this software without specific prior written permission.
     16  *
     17  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
     18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     20  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
     21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27  */
     28 
     29 #import <Foundation/Foundation.h>
     30 
     31 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
     32 #define WebNSUInteger unsigned int
     33 #else
     34 #define WebNSUInteger NSUInteger
     35 #endif
     36 
     37 @class WebHistoryItem;
     38 @class WebBackForwardListPrivate;
     39 
     40 /*!
     41     @class WebBackForwardList
     42     WebBackForwardList holds an ordered list of WebHistoryItems that comprises the back and
     43     forward lists.
     44 
     45     Note that the methods which modify instances of this class do not cause
     46     navigation to happen in other layers of the stack;  they are only for maintaining this data
     47     structure.
     48 */
     49 @interface WebBackForwardList : NSObject {
     50 @private
     51     WebBackForwardListPrivate *_private;
     52 }
     53 
     54 /*!
     55     @method addItem:
     56     @abstract Adds an entry to the list.
     57     @param entry The entry to add.
     58     @discussion The added entry is inserted immediately after the current entry.
     59     If the current position in the list is not at the end of the list, elements in the
     60     forward list will be dropped at this point.  In addition, entries may be dropped to keep
     61     the size of the list within the maximum size.
     62 */
     63 - (void)addItem:(WebHistoryItem *)item;
     64 
     65 /*!
     66     @method goBack
     67     @abstract Move the current pointer back to the entry before the current entry.
     68 */
     69 - (void)goBack;
     70 
     71 /*!
     72     @method goForward
     73     @abstract Move the current pointer ahead to the entry after the current entry.
     74 */
     75 - (void)goForward;
     76 
     77 /*!
     78     @method goToItem:
     79     @abstract Move the current pointer to the given entry.
     80     @param item The history item to move the pointer to
     81 */
     82 - (void)goToItem:(WebHistoryItem *)item;
     83 
     84 /*!
     85     @method backItem
     86     @abstract Returns the entry right before the current entry.
     87     @result The entry right before the current entry, or nil if there isn't one.
     88 */
     89 - (WebHistoryItem *)backItem;
     90 
     91 /*!
     92     @method currentItem
     93     @abstract Returns the current entry.
     94     @result The current entry.
     95 */
     96 - (WebHistoryItem *)currentItem;
     97 
     98 /*!
     99     @method forwardItem
    100     @abstract Returns the entry right after the current entry.
    101     @result The entry right after the current entry, or nil if there isn't one.
    102 */
    103 - (WebHistoryItem *)forwardItem;
    104 
    105 /*!
    106     @method backListWithLimit:
    107     @abstract Returns a portion of the list before the current entry.
    108     @param limit A cap on the size of the array returned.
    109     @result An array of items before the current entry, or nil if there are none.  The entries are in the order that they were originally visited.
    110 */
    111 - (NSArray *)backListWithLimit:(int)limit;
    112 
    113 /*!
    114     @method forwardListWithLimit:
    115     @abstract Returns a portion of the list after the current entry.
    116     @param limit A cap on the size of the array returned.
    117     @result An array of items after the current entry, or nil if there are none.  The entries are in the order that they were originally visited.
    118 */
    119 - (NSArray *)forwardListWithLimit:(int)limit;
    120 
    121 /*!
    122     @method capacity
    123     @abstract Returns the list's maximum size.
    124     @result The list's maximum size.
    125 */
    126 - (int)capacity;
    127 
    128 /*!
    129     @method setCapacity
    130     @abstract Sets the list's maximum size.
    131     @param size The new maximum size for the list.
    132 */
    133 - (void)setCapacity:(int)size;
    134 
    135 /*!
    136     @method backListCount
    137     @abstract Returns the back list's current count.
    138     @result The number of items in the list.
    139 */
    140 - (int)backListCount;
    141 
    142 /*!
    143     @method forwardListCount
    144     @abstract Returns the forward list's current count.
    145     @result The number of items in the list.
    146 */
    147 - (int)forwardListCount;
    148 
    149 /*!
    150     @method containsItem:
    151     @param item The item that will be checked for presence in the WebBackForwardList.
    152     @result Returns YES if the item is in the list.
    153 */
    154 - (BOOL)containsItem:(WebHistoryItem *)item;
    155 
    156 /*!
    157     @method itemAtIndex:
    158     @abstract Returns an entry the given distance from the current entry.
    159     @param index Index of the desired list item relative to the current item; 0 is current item, -1 is back item, 1 is forward item, etc.
    160     @result The entry the given distance from the current entry. If index exceeds the limits of the list, nil is returned.
    161 */
    162 - (WebHistoryItem *)itemAtIndex:(int)index;
    163 
    164 @end
    165 
    166 @interface WebBackForwardList(WebBackForwardListDeprecated)
    167 
    168 // The following methods are deprecated, and exist for backward compatibility only.
    169 // Use -[WebPreferences setUsesPageCache] and -[WebPreferences usesPageCache]
    170 // instead.
    171 
    172 /*!
    173     @method setPageCacheSize:
    174     @abstract The size passed to this method determines whether the WebView
    175     associated with this WebBackForwardList will use the shared page cache.
    176     @param size If size is 0, the WebView associated with this WebBackForwardList
    177     will not use the shared page cache. Otherwise, it will.
    178 */
    179 - (void)setPageCacheSize:(WebNSUInteger)size;
    180 
    181 /*!
    182     @method pageCacheSize
    183     @abstract Returns the size of the shared page cache, or 0.
    184     @result The size of the shared page cache (in pages), or 0 if the WebView
    185     associated with this WebBackForwardList will not use the shared page cache.
    186 */
    187 - (WebNSUInteger)pageCacheSize;
    188 @end
    189 
    190 #undef WebNSUInteger
    191