Adds a new page to the navigation history. @param page the page to add to the navigation history @return the created history entry
(final Page page)
| 248 | * @return the created history entry |
| 249 | */ |
| 250 | protected HistoryEntry addPage(final Page page) { |
| 251 | final Boolean ignoreNewPages = ignoreNewPages_.get(); |
| 252 | if (ignoreNewPages != null && ignoreNewPages.booleanValue()) { |
| 253 | return null; |
| 254 | } |
| 255 | |
| 256 | final int sizeLimit = window_.getWebClient().getOptions().getHistorySizeLimit(); |
| 257 | if (sizeLimit <= 0) { |
| 258 | entries_.clear(); |
| 259 | index_ = -1; |
| 260 | return null; |
| 261 | } |
| 262 | |
| 263 | index_++; |
| 264 | while (entries_.size() > index_) { |
| 265 | entries_.remove(index_); |
| 266 | } |
| 267 | while (entries_.size() >= sizeLimit) { |
| 268 | entries_.remove(0); |
| 269 | index_--; |
| 270 | } |
| 271 | |
| 272 | final HistoryEntry entry = new HistoryEntry(page); |
| 273 | entries_.add(entry); |
| 274 | |
| 275 | final int cacheLimit = Math.max(window_.getWebClient().getOptions().getHistoryPageCacheLimit(), 0); |
| 276 | if (entries_.size() > cacheLimit) { |
| 277 | entries_.get(entries_.size() - cacheLimit - 1).clearPage(); |
| 278 | } |
| 279 | |
| 280 | return entry; |
| 281 | } |
| 282 | |
| 283 | /** |
| 284 | * Loads the URL at the current index into the window to which this navigation history belongs. |
no test coverage detected