Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: Source/core/loader/HistoryController.cpp

Issue 31063004: Have Frame::loader() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/loader/FrameLoader.cpp ('k') | Source/core/loader/MixedContentChecker.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 1) If first layout happens before the load completes, we want to restore the sc roll position then so that the 74 1) If first layout happens before the load completes, we want to restore the sc roll position then so that the
75 first time we draw the page is already scrolled to the right place, instead of starting at the top and later 75 first time we draw the page is already scrolled to the right place, instead of starting at the top and later
76 jumping down. It is possible that the old scroll position is past the part of the doc laid out so far, in 76 jumping down. It is possible that the old scroll position is past the part of the doc laid out so far, in
77 which case the restore silent fails and we will fix it in when we try to restor e on doc completion. 77 which case the restore silent fails and we will fix it in when we try to restor e on doc completion.
78 2) If the layout happens after the load completes, the attempt to restore at lo ad completion time silently 78 2) If the layout happens after the load completes, the attempt to restore at lo ad completion time silently
79 fails. We then successfully restore it when the layout happens. 79 fails. We then successfully restore it when the layout happens.
80 */ 80 */
81 void HistoryController::restoreScrollPositionAndViewState() 81 void HistoryController::restoreScrollPositionAndViewState()
82 { 82 {
83 if (!m_currentItem || !m_frame->loader()->stateMachine()->committedFirstReal DocumentLoad()) 83 if (!m_currentItem || !m_frame->loader().stateMachine()->committedFirstRealD ocumentLoad())
84 return; 84 return;
85 85
86 if (FrameView* view = m_frame->view()) { 86 if (FrameView* view = m_frame->view()) {
87 Page* page = m_frame->page(); 87 Page* page = m_frame->page();
88 if (page && page->mainFrame() == m_frame) { 88 if (page && page->mainFrame() == m_frame) {
89 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoor dinator()) 89 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoor dinator())
90 scrollingCoordinator->frameViewRootLayerDidChange(view); 90 scrollingCoordinator->frameViewRootLayerDidChange(view);
91 } 91 }
92 92
93 if (!view->wasScrolledByUser()) { 93 if (!view->wasScrolledByUser()) {
(...skipping 28 matching lines...) Expand all
122 122
123 m_currentItem->setScrollPoint(m_frame->view()->scrollPosition()); 123 m_currentItem->setScrollPoint(m_frame->view()->scrollPosition());
124 124
125 Page* page = m_frame->page(); 125 Page* page = m_frame->page();
126 if (page && page->mainFrame() == m_frame) 126 if (page && page->mainFrame() == m_frame)
127 m_currentItem->setPageScaleFactor(page->pageScaleFactor()); 127 m_currentItem->setPageScaleFactor(page->pageScaleFactor());
128 } 128 }
129 129
130 void HistoryController::restoreDocumentState() 130 void HistoryController::restoreDocumentState()
131 { 131 {
132 if (m_currentItem && m_frame->loader()->loadType() == FrameLoadTypeBackForwa rd) 132 if (m_currentItem && m_frame->loader().loadType() == FrameLoadTypeBackForwar d)
133 m_frame->document()->setStateForNewFormElements(m_currentItem->documentS tate()); 133 m_frame->document()->setStateForNewFormElements(m_currentItem->documentS tate());
134 } 134 }
135 135
136 bool HistoryController::shouldStopLoadingForHistoryItem(HistoryItem* targetItem) const 136 bool HistoryController::shouldStopLoadingForHistoryItem(HistoryItem* targetItem) const
137 { 137 {
138 if (!m_currentItem) 138 if (!m_currentItem)
139 return false; 139 return false;
140 // Don't abort the current load if we're navigating within the current docum ent. 140 // Don't abort the current load if we're navigating within the current docum ent.
141 return !m_currentItem->shouldDoSameDocumentNavigationTo(targetItem); 141 return !m_currentItem->shouldDoSameDocumentNavigationTo(targetItem);
142 } 142 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 m_defersLoading = defer; 175 m_defersLoading = defer;
176 if (!defer && m_deferredItem) { 176 if (!defer && m_deferredItem) {
177 goToItem(m_deferredItem.get()); 177 goToItem(m_deferredItem.get());
178 m_deferredItem = 0; 178 m_deferredItem = 0;
179 } 179 }
180 } 180 }
181 181
182 void HistoryController::clearProvisionalItemsInAllFrames() 182 void HistoryController::clearProvisionalItemsInAllFrames()
183 { 183 {
184 for (RefPtr<Frame> frame = m_frame->page()->mainFrame(); frame; frame = fram e->tree().traverseNext()) 184 for (RefPtr<Frame> frame = m_frame->page()->mainFrame(); frame; frame = fram e->tree().traverseNext())
185 frame->loader()->history()->m_provisionalItem = 0; 185 frame->loader().history()->m_provisionalItem = 0;
186 } 186 }
187 187
188 // There are 2 things you might think of as "history", all of which are handled by these functions. 188 // There are 2 things you might think of as "history", all of which are handled by these functions.
189 // 189 //
190 // 1) Back/forward: The m_currentItem is part of this mechanism. 190 // 1) Back/forward: The m_currentItem is part of this mechanism.
191 // 2) Global history: Handled by the client. 191 // 2) Global history: Handled by the client.
192 // 192 //
193 void HistoryController::updateForStandardLoad() 193 void HistoryController::updateForStandardLoad()
194 { 194 {
195 LOG(History, "WebCoreHistory: Updating History for Standard Load in frame %s ", m_frame->loader()->documentLoader()->url().string().ascii().data()); 195 LOG(History, "WebCoreHistory: Updating History for Standard Load in frame %s ", m_frame->loader().documentLoader()->url().string().ascii().data());
196 createNewBackForwardItem(true); 196 createNewBackForwardItem(true);
197 } 197 }
198 198
199 void HistoryController::updateForInitialLoadInChildFrame() 199 void HistoryController::updateForInitialLoadInChildFrame()
200 { 200 {
201 Frame* parentFrame = m_frame->tree().parent(); 201 Frame* parentFrame = m_frame->tree().parent();
202 if (parentFrame && parentFrame->loader()->history()->m_currentItem) 202 if (parentFrame && parentFrame->loader().history()->m_currentItem)
203 parentFrame->loader()->history()->m_currentItem->setChildItem(createItem ()); 203 parentFrame->loader().history()->m_currentItem->setChildItem(createItem( ));
204 } 204 }
205 205
206 void HistoryController::updateForCommit() 206 void HistoryController::updateForCommit()
207 { 207 {
208 FrameLoader* frameLoader = m_frame->loader(); 208 FrameLoader& frameLoader = m_frame->loader();
209 #if !LOG_DISABLED 209 #if !LOG_DISABLED
210 if (m_frame->document()) 210 if (m_frame->document())
211 LOG(History, "WebCoreHistory: Updating History for commit in frame %s", m_frame->document()->title().utf8().data()); 211 LOG(History, "WebCoreHistory: Updating History for commit in frame %s", m_frame->document()->title().utf8().data());
212 #endif 212 #endif
213 FrameLoadType type = frameLoader->loadType(); 213 FrameLoadType type = frameLoader.loadType();
214 if (isBackForwardLoadType(type)) { 214 if (isBackForwardLoadType(type)) {
215 // Once committed, we want to use current item for saving DocState, and 215 // Once committed, we want to use current item for saving DocState, and
216 // the provisional item for restoring state. 216 // the provisional item for restoring state.
217 // Note previousItem must be set before we close the URL, which will 217 // Note previousItem must be set before we close the URL, which will
218 // happen when the data source is made non-provisional below 218 // happen when the data source is made non-provisional below
219 m_previousItem = m_currentItem; 219 m_previousItem = m_currentItem;
220 ASSERT(m_provisionalItem); 220 ASSERT(m_provisionalItem);
221 m_currentItem = m_provisionalItem; 221 m_currentItem = m_provisionalItem;
222 m_provisionalItem = 0; 222 m_provisionalItem = 0;
223 223
224 // Tell all other frames in the tree to commit their provisional items a nd 224 // Tell all other frames in the tree to commit their provisional items a nd
225 // restore their scroll position. We'll avoid this frame (which has alr eady 225 // restore their scroll position. We'll avoid this frame (which has alr eady
226 // committed) and its children (which will be replaced). 226 // committed) and its children (which will be replaced).
227 Page* page = m_frame->page(); 227 Page* page = m_frame->page();
228 ASSERT(page); 228 ASSERT(page);
229 page->mainFrame()->loader()->history()->recursiveUpdateForCommit(); 229 page->mainFrame()->loader().history()->recursiveUpdateForCommit();
230 } else if (type != FrameLoadTypeRedirectWithLockedBackForwardList) { 230 } else if (type != FrameLoadTypeRedirectWithLockedBackForwardList) {
231 m_provisionalItem = 0; 231 m_provisionalItem = 0;
232 } 232 }
233 233
234 if (type == FrameLoadTypeStandard) 234 if (type == FrameLoadTypeStandard)
235 updateForStandardLoad(); 235 updateForStandardLoad();
236 else if (type == FrameLoadTypeInitialInChildFrame) 236 else if (type == FrameLoadTypeInitialInChildFrame)
237 updateForInitialLoadInChildFrame(); 237 updateForInitialLoadInChildFrame();
238 else 238 else
239 updateWithoutCreatingNewBackForwardItem(); 239 updateWithoutCreatingNewBackForwardItem();
(...skipping 17 matching lines...) Expand all
257 m_previousItem = m_currentItem; 257 m_previousItem = m_currentItem;
258 m_currentItem = m_provisionalItem; 258 m_currentItem = m_provisionalItem;
259 m_provisionalItem = 0; 259 m_provisionalItem = 0;
260 260
261 // Restore the scroll position (we choose to do this rather than going b ack to the anchor point) 261 // Restore the scroll position (we choose to do this rather than going b ack to the anchor point)
262 restoreScrollPositionAndViewState(); 262 restoreScrollPositionAndViewState();
263 } 263 }
264 264
265 // Iterate over the rest of the tree 265 // Iterate over the rest of the tree
266 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) 266 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling())
267 child->loader()->history()->recursiveUpdateForCommit(); 267 child->loader().history()->recursiveUpdateForCommit();
268 } 268 }
269 269
270 void HistoryController::updateForSameDocumentNavigation() 270 void HistoryController::updateForSameDocumentNavigation()
271 { 271 {
272 if (m_frame->document()->url().isEmpty()) 272 if (m_frame->document()->url().isEmpty())
273 return; 273 return;
274 274
275 Page* page = m_frame->page(); 275 Page* page = m_frame->page();
276 if (!page) 276 if (!page)
277 return; 277 return;
278 278
279 page->mainFrame()->loader()->history()->recursiveUpdateForSameDocumentNaviga tion(); 279 page->mainFrame()->loader().history()->recursiveUpdateForSameDocumentNavigat ion();
280 280
281 if (m_currentItem) 281 if (m_currentItem)
282 m_currentItem->setURL(m_frame->document()->url()); 282 m_currentItem->setURL(m_frame->document()->url());
283 } 283 }
284 284
285 void HistoryController::recursiveUpdateForSameDocumentNavigation() 285 void HistoryController::recursiveUpdateForSameDocumentNavigation()
286 { 286 {
287 // The frame that navigated will now have a null provisional item. 287 // The frame that navigated will now have a null provisional item.
288 // Ignore it and its children. 288 // Ignore it and its children.
289 if (!m_provisionalItem) 289 if (!m_provisionalItem)
290 return; 290 return;
291 291
292 // The provisional item may represent a different pending navigation. 292 // The provisional item may represent a different pending navigation.
293 // Don't commit it if it isn't a same document navigation. 293 // Don't commit it if it isn't a same document navigation.
294 if (m_currentItem && !m_currentItem->shouldDoSameDocumentNavigationTo(m_prov isionalItem.get())) 294 if (m_currentItem && !m_currentItem->shouldDoSameDocumentNavigationTo(m_prov isionalItem.get()))
295 return; 295 return;
296 296
297 // Commit the provisional item. 297 // Commit the provisional item.
298 m_previousItem = m_currentItem; 298 m_previousItem = m_currentItem;
299 m_currentItem = m_provisionalItem; 299 m_currentItem = m_provisionalItem;
300 m_provisionalItem = 0; 300 m_provisionalItem = 0;
301 301
302 // Iterate over the rest of the tree. 302 // Iterate over the rest of the tree.
303 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) 303 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling())
304 child->loader()->history()->recursiveUpdateForSameDocumentNavigation(); 304 child->loader().history()->recursiveUpdateForSameDocumentNavigation();
305 } 305 }
306 306
307 void HistoryController::setCurrentItem(HistoryItem* item) 307 void HistoryController::setCurrentItem(HistoryItem* item)
308 { 308 {
309 m_previousItem = m_currentItem; 309 m_previousItem = m_currentItem;
310 m_currentItem = item; 310 m_currentItem = item;
311 } 311 }
312 312
313 bool HistoryController::currentItemShouldBeReplaced() const 313 bool HistoryController::currentItemShouldBeReplaced() const
314 { 314 {
315 // From the HTML5 spec for location.assign(): 315 // From the HTML5 spec for location.assign():
316 // "If the browsing context's session history contains only one Document, 316 // "If the browsing context's session history contains only one Document,
317 // and that was the about:blank Document created when the browsing context 317 // and that was the about:blank Document created when the browsing context
318 // was created, then the navigation must be done with replacement enabled. " 318 // was created, then the navigation must be done with replacement enabled. "
319 return m_currentItem && !m_previousItem && equalIgnoringCase(m_currentItem-> urlString(), blankURL()); 319 return m_currentItem && !m_previousItem && equalIgnoringCase(m_currentItem-> urlString(), blankURL());
320 } 320 }
321 321
322 void HistoryController::setProvisionalItem(HistoryItem* item) 322 void HistoryController::setProvisionalItem(HistoryItem* item)
323 { 323 {
324 m_provisionalItem = item; 324 m_provisionalItem = item;
325 } 325 }
326 326
327 void HistoryController::initializeItem(HistoryItem* item) 327 void HistoryController::initializeItem(HistoryItem* item)
328 { 328 {
329 DocumentLoader* documentLoader = m_frame->loader()->documentLoader(); 329 DocumentLoader* documentLoader = m_frame->loader().documentLoader();
330 ASSERT(documentLoader); 330 ASSERT(documentLoader);
331 331
332 KURL unreachableURL = documentLoader->unreachableURL(); 332 KURL unreachableURL = documentLoader->unreachableURL();
333 333
334 KURL url; 334 KURL url;
335 KURL originalURL; 335 KURL originalURL;
336 336
337 if (!unreachableURL.isEmpty()) { 337 if (!unreachableURL.isEmpty()) {
338 url = unreachableURL; 338 url = unreachableURL;
339 originalURL = unreachableURL; 339 originalURL = unreachableURL;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 if (m_previousItem) { 387 if (m_previousItem) {
388 if (m_frame != targetFrame) 388 if (m_frame != targetFrame)
389 bfItem->setItemSequenceNumber(m_previousItem->itemSequenceNumber ()); 389 bfItem->setItemSequenceNumber(m_previousItem->itemSequenceNumber ());
390 bfItem->setDocumentSequenceNumber(m_previousItem->documentSequenceNu mber()); 390 bfItem->setDocumentSequenceNumber(m_previousItem->documentSequenceNu mber());
391 } 391 }
392 392
393 for (Frame* child = m_frame->tree().firstChild(); child; child = child-> tree().nextSibling()) { 393 for (Frame* child = m_frame->tree().firstChild(); child; child = child-> tree().nextSibling()) {
394 // If the child is a frame corresponding to an <object> element that never loaded, 394 // If the child is a frame corresponding to an <object> element that never loaded,
395 // we don't want to create a history item, because that causes fallb ack content 395 // we don't want to create a history item, because that causes fallb ack content
396 // to be ignored on reload. 396 // to be ignored on reload.
397 FrameLoader* childLoader = child->loader(); 397 FrameLoader& childLoader = child->loader();
398 if (childLoader->stateMachine()->startedFirstRealLoad() || !child->o wnerElement()->isObjectElement()) 398 if (childLoader.stateMachine()->startedFirstRealLoad() || !child->ow nerElement()->isObjectElement())
399 bfItem->addChildItem(childLoader->history()->createItemTree(targ etFrame, clipAtTarget)); 399 bfItem->addChildItem(childLoader.history()->createItemTree(targe tFrame, clipAtTarget));
400 } 400 }
401 } 401 }
402 return bfItem; 402 return bfItem;
403 } 403 }
404 404
405 // The general idea here is to traverse the frame tree and the item tree in para llel, 405 // The general idea here is to traverse the frame tree and the item tree in para llel,
406 // tracking whether each frame already has the content the item requests. If th ere is 406 // tracking whether each frame already has the content the item requests. If th ere is
407 // a match, we set the provisional item and recurse. Otherwise we will reload t hat 407 // a match, we set the provisional item and recurse. Otherwise we will reload t hat
408 // frame and all its kids in recursiveGoToItem. 408 // frame and all its kids in recursiveGoToItem.
409 void HistoryController::recursiveSetProvisionalItem(HistoryItem* item, HistoryIt em* fromItem) 409 void HistoryController::recursiveSetProvisionalItem(HistoryItem* item, HistoryIt em* fromItem)
410 { 410 {
411 ASSERT(item); 411 ASSERT(item);
412 412
413 if (itemsAreClones(item, fromItem)) { 413 if (itemsAreClones(item, fromItem)) {
414 // Set provisional item, which will be committed in recursiveUpdateForCo mmit. 414 // Set provisional item, which will be committed in recursiveUpdateForCo mmit.
415 m_provisionalItem = item; 415 m_provisionalItem = item;
416 416
417 const HistoryItemVector& childItems = item->children(); 417 const HistoryItemVector& childItems = item->children();
418 418
419 int size = childItems.size(); 419 int size = childItems.size();
420 420
421 for (int i = 0; i < size; ++i) { 421 for (int i = 0; i < size; ++i) {
422 String childFrameName = childItems[i]->target(); 422 String childFrameName = childItems[i]->target();
423 HistoryItem* fromChildItem = fromItem->childItemWithTarget(childFram eName); 423 HistoryItem* fromChildItem = fromItem->childItemWithTarget(childFram eName);
424 ASSERT(fromChildItem); 424 ASSERT(fromChildItem);
425 Frame* childFrame = m_frame->tree().child(childFrameName); 425 Frame* childFrame = m_frame->tree().child(childFrameName);
426 ASSERT(childFrame); 426 ASSERT(childFrame);
427 childFrame->loader()->history()->recursiveSetProvisionalItem(childIt ems[i].get(), fromChildItem); 427 childFrame->loader().history()->recursiveSetProvisionalItem(childIte ms[i].get(), fromChildItem);
428 } 428 }
429 } 429 }
430 } 430 }
431 431
432 // We now traverse the frame tree and item tree a second time, loading frames th at 432 // We now traverse the frame tree and item tree a second time, loading frames th at
433 // do have the content the item requests. 433 // do have the content the item requests.
434 void HistoryController::recursiveGoToItem(HistoryItem* item, HistoryItem* fromIt em) 434 void HistoryController::recursiveGoToItem(HistoryItem* item, HistoryItem* fromIt em)
435 { 435 {
436 ASSERT(item); 436 ASSERT(item);
437 437
438 if (itemsAreClones(item, fromItem)) { 438 if (itemsAreClones(item, fromItem)) {
439 // Just iterate over the rest, looking for frames to navigate. 439 // Just iterate over the rest, looking for frames to navigate.
440 const HistoryItemVector& childItems = item->children(); 440 const HistoryItemVector& childItems = item->children();
441 441
442 int size = childItems.size(); 442 int size = childItems.size();
443 for (int i = 0; i < size; ++i) { 443 for (int i = 0; i < size; ++i) {
444 String childFrameName = childItems[i]->target(); 444 String childFrameName = childItems[i]->target();
445 HistoryItem* fromChildItem = fromItem->childItemWithTarget(childFram eName); 445 HistoryItem* fromChildItem = fromItem->childItemWithTarget(childFram eName);
446 ASSERT(fromChildItem); 446 ASSERT(fromChildItem);
447 Frame* childFrame = m_frame->tree().child(childFrameName); 447 Frame* childFrame = m_frame->tree().child(childFrameName);
448 ASSERT(childFrame); 448 ASSERT(childFrame);
449 childFrame->loader()->history()->recursiveGoToItem(childItems[i].get (), fromChildItem); 449 childFrame->loader().history()->recursiveGoToItem(childItems[i].get( ), fromChildItem);
450 } 450 }
451 } else { 451 } else {
452 m_frame->loader()->loadHistoryItem(item); 452 m_frame->loader().loadHistoryItem(item);
453 } 453 }
454 } 454 }
455 455
456 bool HistoryController::itemsAreClones(HistoryItem* item1, HistoryItem* item2) c onst 456 bool HistoryController::itemsAreClones(HistoryItem* item1, HistoryItem* item2) c onst
457 { 457 {
458 // If the item we're going to is a clone of the item we're at, then we do 458 // If the item we're going to is a clone of the item we're at, then we do
459 // not need to load it again. The current frame tree and the frame tree 459 // not need to load it again. The current frame tree and the frame tree
460 // snapshot in the item have to match. 460 // snapshot in the item have to match.
461 // Note: Some clients treat a navigation to the current history item as 461 // Note: Some clients treat a navigation to the current history item as
462 // a reload. Thus, if item1 and item2 are the same, we need to create a 462 // a reload. Thus, if item1 and item2 are the same, we need to create a
(...skipping 30 matching lines...) Expand all
493 { 493 {
494 // In the case of saving state about a page with frames, we store a tree of items that mirrors the frame tree. 494 // In the case of saving state about a page with frames, we store a tree of items that mirrors the frame tree.
495 // The item that was the target of the user's navigation is designated as th e "targetItem". 495 // The item that was the target of the user's navigation is designated as th e "targetItem".
496 // When this function is called with doClip=true we're able to create the wh ole tree except for the target's children, 496 // When this function is called with doClip=true we're able to create the wh ole tree except for the target's children,
497 // which will be loaded in the future. That part of the tree will be filled out as the child loads are committed. 497 // which will be loaded in the future. That part of the tree will be filled out as the child loads are committed.
498 498
499 Page* page = m_frame->page(); 499 Page* page = m_frame->page();
500 if (!page) 500 if (!page)
501 return; 501 return;
502 502
503 if (!m_frame->loader()->documentLoader()->isURLValidForNewHistoryEntry()) 503 if (!m_frame->loader().documentLoader()->isURLValidForNewHistoryEntry())
504 return; 504 return;
505 505
506 Frame* mainFrame = page->mainFrame(); 506 Frame* mainFrame = page->mainFrame();
507 ASSERT(mainFrame); 507 ASSERT(mainFrame);
508 508
509 RefPtr<HistoryItem> topItem = mainFrame->loader()->history()->createItemTree (m_frame, doClip); 509 RefPtr<HistoryItem> topItem = mainFrame->loader().history()->createItemTree( m_frame, doClip);
510 LOG(BackForward, "WebCoreBackForward - Adding backforward item %p for frame %s", topItem.get(), m_frame->loader()->documentLoader()->url().string().ascii(). data()); 510 LOG(BackForward, "WebCoreBackForward - Adding backforward item %p for frame %s", topItem.get(), m_frame->loader().documentLoader()->url().string().ascii().d ata());
511 } 511 }
512 512
513 void HistoryController::updateWithoutCreatingNewBackForwardItem() 513 void HistoryController::updateWithoutCreatingNewBackForwardItem()
514 { 514 {
515 if (!m_currentItem) 515 if (!m_currentItem)
516 return; 516 return;
517 517
518 DocumentLoader* documentLoader = m_frame->loader()->documentLoader(); 518 DocumentLoader* documentLoader = m_frame->loader().documentLoader();
519 519
520 if (!documentLoader->unreachableURL().isEmpty()) 520 if (!documentLoader->unreachableURL().isEmpty())
521 return; 521 return;
522 522
523 if (m_currentItem->url() != documentLoader->url()) { 523 if (m_currentItem->url() != documentLoader->url()) {
524 m_currentItem->reset(); 524 m_currentItem->reset();
525 initializeItem(m_currentItem.get()); 525 initializeItem(m_currentItem.get());
526 } else { 526 } else {
527 // Even if the final URL didn't change, the form data may have changed. 527 // Even if the final URL didn't change, the form data may have changed.
528 m_currentItem->setFormInfoFromRequest(documentLoader->request()); 528 m_currentItem->setFormInfoFromRequest(documentLoader->request());
529 } 529 }
530 } 530 }
531 531
532 void HistoryController::pushState(PassRefPtr<SerializedScriptValue> stateObject, const String& urlString) 532 void HistoryController::pushState(PassRefPtr<SerializedScriptValue> stateObject, const String& urlString)
533 { 533 {
534 if (!m_currentItem) 534 if (!m_currentItem)
535 return; 535 return;
536 536
537 Page* page = m_frame->page(); 537 Page* page = m_frame->page();
538 ASSERT(page); 538 ASSERT(page);
539 539
540 // Get a HistoryItem tree for the current frame tree. 540 // Get a HistoryItem tree for the current frame tree.
541 RefPtr<HistoryItem> topItem = page->mainFrame()->loader()->history()->create ItemTree(m_frame, false); 541 RefPtr<HistoryItem> topItem = page->mainFrame()->loader().history()->createI temTree(m_frame, false);
542 542
543 // Override data in the current item (created by createItemTree) to reflect 543 // Override data in the current item (created by createItemTree) to reflect
544 // the pushState() arguments. 544 // the pushState() arguments.
545 m_currentItem->setStateObject(stateObject); 545 m_currentItem->setStateObject(stateObject);
546 m_currentItem->setURLString(urlString); 546 m_currentItem->setURLString(urlString);
547 } 547 }
548 548
549 void HistoryController::replaceState(PassRefPtr<SerializedScriptValue> stateObje ct, const String& urlString) 549 void HistoryController::replaceState(PassRefPtr<SerializedScriptValue> stateObje ct, const String& urlString)
550 { 550 {
551 if (!m_currentItem) 551 if (!m_currentItem)
552 return; 552 return;
553 553
554 if (!urlString.isEmpty()) 554 if (!urlString.isEmpty())
555 m_currentItem->setURLString(urlString); 555 m_currentItem->setURLString(urlString);
556 m_currentItem->setStateObject(stateObject); 556 m_currentItem->setStateObject(stateObject);
557 m_currentItem->setFormData(0); 557 m_currentItem->setFormData(0);
558 m_currentItem->setFormContentType(String()); 558 m_currentItem->setFormContentType(String());
559 559
560 ASSERT(m_frame->page()); 560 ASSERT(m_frame->page());
561 } 561 }
562 562
563 } // namespace WebCore 563 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/loader/FrameLoader.cpp ('k') | Source/core/loader/MixedContentChecker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698