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

Side by Side Diff: Source/web/WebFrameImpl.cpp

Issue 28983004: Split the frame tree logic out of HistoryItem (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 frame()->loader().load(FrameLoadRequest(0, resourceRequest)); 919 frame()->loader().load(FrameLoadRequest(0, resourceRequest));
920 } 920 }
921 921
922 void WebFrameImpl::loadHistoryItem(const WebHistoryItem& item) 922 void WebFrameImpl::loadHistoryItem(const WebHistoryItem& item)
923 { 923 {
924 ASSERT(frame()); 924 ASSERT(frame());
925 RefPtr<HistoryItem> historyItem = PassRefPtr<HistoryItem>(item); 925 RefPtr<HistoryItem> historyItem = PassRefPtr<HistoryItem>(item);
926 ASSERT(historyItem); 926 ASSERT(historyItem);
927 927
928 frame()->loader().prepareForHistoryNavigation(); 928 frame()->loader().prepareForHistoryNavigation();
929 RefPtr<HistoryItem> currentItem = frame()->loader().history()->currentItem() ; 929 m_inSameDocumentHistoryLoad = frame()->loader().history()->shouldPerformSame DocumentHistoryNavigation(frame(), historyItem.get());
930 m_inSameDocumentHistoryLoad = currentItem && currentItem->shouldDoSameDocume ntNavigationTo(historyItem.get());
931 frame()->page()->goToItem(historyItem.get()); 930 frame()->page()->goToItem(historyItem.get());
932 m_inSameDocumentHistoryLoad = false; 931 m_inSameDocumentHistoryLoad = false;
933 } 932 }
934 933
935 void WebFrameImpl::loadData(const WebData& data, const WebString& mimeType, cons t WebString& textEncoding, const WebURL& baseURL, const WebURL& unreachableURL, bool replace) 934 void WebFrameImpl::loadData(const WebData& data, const WebString& mimeType, cons t WebString& textEncoding, const WebURL& baseURL, const WebURL& unreachableURL, bool replace)
936 { 935 {
937 ASSERT(frame()); 936 ASSERT(frame());
938 937
939 // If we are loading substitute data to replace an existing load, then 938 // If we are loading substitute data to replace an existing load, then
940 // inherit all of the properties of that original request. This way, 939 // inherit all of the properties of that original request. This way,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 return DataSourceForDocLoader(frame()->loader().documentLoader()); 992 return DataSourceForDocLoader(frame()->loader().documentLoader());
994 } 993 }
995 994
996 WebHistoryItem WebFrameImpl::previousHistoryItem() const 995 WebHistoryItem WebFrameImpl::previousHistoryItem() const
997 { 996 {
998 ASSERT(frame()); 997 ASSERT(frame());
999 // We use the previous item here because documentState (filled-out forms) 998 // We use the previous item here because documentState (filled-out forms)
1000 // only get saved to history when it becomes the previous item. The caller 999 // only get saved to history when it becomes the previous item. The caller
1001 // is expected to query the history item after a navigation occurs, after 1000 // is expected to query the history item after a navigation occurs, after
1002 // the desired history item has become the previous entry. 1001 // the desired history item has become the previous entry.
1003 return WebHistoryItem(frame()->loader().history()->previousItem()); 1002 return WebHistoryItem(frame()->loader().history()->previousItemForExport(fra me()));
1004 } 1003 }
1005 1004
1006 WebHistoryItem WebFrameImpl::currentHistoryItem() const 1005 WebHistoryItem WebFrameImpl::currentHistoryItem() const
1007 { 1006 {
1008 ASSERT(frame()); 1007 ASSERT(frame());
1009 1008
1010 // We're shutting down. 1009 // We're shutting down.
1011 if (!frame()->loader().activeDocumentLoader()) 1010 if (!frame()->loader().activeDocumentLoader())
1012 return WebHistoryItem(); 1011 return WebHistoryItem();
1013 1012
1014 // If we are still loading, then we don't want to clobber the current 1013 // If we are still loading, then we don't want to clobber the current
1015 // history item as this could cause us to lose the scroll position and 1014 // history item as this could cause us to lose the scroll position and
1016 // document state. However, it is OK for new navigations. 1015 // document state. However, it is OK for new navigations.
1017 // FIXME: Can we make this a plain old getter, instead of worrying about 1016 // FIXME: Can we make this a plain old getter, instead of worrying about
1018 // clobbering here? 1017 // clobbering here?
1019 if (!m_inSameDocumentHistoryLoad && (frame()->loader().loadType() == FrameLo adTypeStandard 1018 if (!m_inSameDocumentHistoryLoad && (frame()->loader().loadType() == FrameLo adTypeStandard
1020 || !frame()->loader().activeDocumentLoader()->isLoadingInAPISense())) 1019 || !frame()->loader().activeDocumentLoader()->isLoadingInAPISense()))
1021 frame()->loader().history()->saveDocumentAndScrollState(); 1020 frame()->loader().history()->saveDocumentAndScrollState(frame());
1022 1021
1023 if (HistoryItem* item = frame()->loader().history()->provisionalItem()) 1022 if (RefPtr<HistoryItem> item = frame()->loader().history()->provisionalItemF orExport(frame()))
1024 return WebHistoryItem(item); 1023 return WebHistoryItem(item);
1025 return WebHistoryItem(frame()->page()->mainFrame()->loader().history()->curr entItem()); 1024 return WebHistoryItem(frame()->loader().history()->currentItemForExport(fram e()));
1026 } 1025 }
1027 1026
1028 void WebFrameImpl::enableViewSourceMode(bool enable) 1027 void WebFrameImpl::enableViewSourceMode(bool enable)
1029 { 1028 {
1030 if (frame()) 1029 if (frame())
1031 frame()->setInViewSourceMode(enable); 1030 frame()->setInViewSourceMode(enable);
1032 } 1031 }
1033 1032
1034 bool WebFrameImpl::isViewSourceModeEnabled() const 1033 bool WebFrameImpl::isViewSourceModeEnabled() const
1035 { 1034 {
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2191 // onload event handler. 2190 // onload event handler.
2192 // Because the event handler may set webframe->mFrame to null, 2191 // Because the event handler may set webframe->mFrame to null,
2193 // it is necessary to check the value after calling init() and 2192 // it is necessary to check the value after calling init() and
2194 // return without loading URL. 2193 // return without loading URL.
2195 // NOTE: m_client will be null if this frame has been detached. 2194 // NOTE: m_client will be null if this frame has been detached.
2196 // (b:791612) 2195 // (b:791612)
2197 childFrame->init(); // create an empty document 2196 childFrame->init(); // create an empty document
2198 if (!childFrame->tree().parent()) 2197 if (!childFrame->tree().parent())
2199 return 0; 2198 return 0;
2200 2199
2201 HistoryItem* parentItem = frame()->loader().history()->currentItem();
2202 HistoryItem* childItem = 0; 2200 HistoryItem* childItem = 0;
2203 // If we're moving in the back/forward list, we might want to replace the co ntent 2201 // If we're moving in the back/forward list, we might want to replace the co ntent
2204 // of this child frame with whatever was there at that point. 2202 // of this child frame with whatever was there at that point.
2205 if (parentItem && parentItem->children().size() && isBackForwardLoadType(fra me()->loader().loadType()) && !frame()->document()->loadEventFinished()) 2203 if (isBackForwardLoadType(frame()->loader().loadType()) && !frame()->documen t()->loadEventFinished())
2206 childItem = parentItem->childItemWithTarget(childFrame->tree().uniqueNam e()); 2204 childItem = frame()->loader().history()->currentItem(childFrame.get());
2207 2205
2208 if (childItem) 2206 if (childItem)
2209 childFrame->loader().loadHistoryItem(childItem); 2207 childFrame->loader().loadHistoryItem(childItem);
2210 else 2208 else
2211 childFrame->loader().load(FrameLoadRequest(0, request.resourceRequest(), "_self")); 2209 childFrame->loader().load(FrameLoadRequest(0, request.resourceRequest(), "_self"));
2212 2210
2213 // A synchronous navigation (about:blank) would have already processed 2211 // A synchronous navigation (about:blank) would have already processed
2214 // onload, so it is possible for the frame to have already been destroyed by 2212 // onload, so it is possible for the frame to have already been destroyed by
2215 // script in the page. 2213 // script in the page.
2216 // NOTE: m_client will be null if this frame has been detached. 2214 // NOTE: m_client will be null if this frame has been detached.
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
2520 2518
2521 // There is a possibility that the frame being detached was the only 2519 // There is a possibility that the frame being detached was the only
2522 // pending one. We need to make sure final replies can be sent. 2520 // pending one. We need to make sure final replies can be sent.
2523 flushCurrentScopingEffort(m_findRequestIdentifier); 2521 flushCurrentScopingEffort(m_findRequestIdentifier);
2524 2522
2525 cancelPendingScopingEffort(); 2523 cancelPendingScopingEffort();
2526 } 2524 }
2527 } 2525 }
2528 2526
2529 } // namespace WebKit 2527 } // namespace WebKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698