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

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, 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
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 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 frame()->loader()->load(FrameLoadRequest(0, resourceRequest)); 917 frame()->loader()->load(FrameLoadRequest(0, resourceRequest));
918 } 918 }
919 919
920 void WebFrameImpl::loadHistoryItem(const WebHistoryItem& item) 920 void WebFrameImpl::loadHistoryItem(const WebHistoryItem& item)
921 { 921 {
922 ASSERT(frame()); 922 ASSERT(frame());
923 RefPtr<HistoryItem> historyItem = PassRefPtr<HistoryItem>(item); 923 RefPtr<HistoryItem> historyItem = PassRefPtr<HistoryItem>(item);
924 ASSERT(historyItem); 924 ASSERT(historyItem);
925 925
926 frame()->loader()->prepareForHistoryNavigation(); 926 frame()->loader()->prepareForHistoryNavigation();
927 RefPtr<HistoryItem> currentItem = frame()->loader()->history()->currentItem( ); 927 m_inSameDocumentHistoryLoad = frame()->loader()->shouldTreatURLAsSameAsCurre nt(historyItem->url());
928 m_inSameDocumentHistoryLoad = currentItem && currentItem->shouldDoSameDocume ntNavigationTo(historyItem.get());
929 frame()->page()->goToItem(historyItem.get()); 928 frame()->page()->goToItem(historyItem.get());
930 m_inSameDocumentHistoryLoad = false; 929 m_inSameDocumentHistoryLoad = false;
931 } 930 }
932 931
933 void WebFrameImpl::loadData(const WebData& data, const WebString& mimeType, cons t WebString& textEncoding, const WebURL& baseURL, const WebURL& unreachableURL, bool replace) 932 void WebFrameImpl::loadData(const WebData& data, const WebString& mimeType, cons t WebString& textEncoding, const WebURL& baseURL, const WebURL& unreachableURL, bool replace)
934 { 933 {
935 ASSERT(frame()); 934 ASSERT(frame());
936 935
937 // If we are loading substitute data to replace an existing load, then 936 // If we are loading substitute data to replace an existing load, then
938 // inherit all of the properties of that original request. This way, 937 // inherit all of the properties of that original request. This way,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 return DataSourceForDocLoader(frame()->loader()->documentLoader()); 990 return DataSourceForDocLoader(frame()->loader()->documentLoader());
992 } 991 }
993 992
994 WebHistoryItem WebFrameImpl::previousHistoryItem() const 993 WebHistoryItem WebFrameImpl::previousHistoryItem() const
995 { 994 {
996 ASSERT(frame()); 995 ASSERT(frame());
997 // We use the previous item here because documentState (filled-out forms) 996 // We use the previous item here because documentState (filled-out forms)
998 // only get saved to history when it becomes the previous item. The caller 997 // only get saved to history when it becomes the previous item. The caller
999 // is expected to query the history item after a navigation occurs, after 998 // is expected to query the history item after a navigation occurs, after
1000 // the desired history item has become the previous entry. 999 // the desired history item has become the previous entry.
1001 return WebHistoryItem(frame()->loader()->history()->previousItem()); 1000 return WebHistoryItem(frame()->loader()->history()->previousItemForExport(fr ame()));
1002 } 1001 }
1003 1002
1004 WebHistoryItem WebFrameImpl::currentHistoryItem() const 1003 WebHistoryItem WebFrameImpl::currentHistoryItem() const
1005 { 1004 {
1006 ASSERT(frame()); 1005 ASSERT(frame());
1007 1006
1008 // We're shutting down. 1007 // We're shutting down.
1009 if (!frame()->loader()->activeDocumentLoader()) 1008 if (!frame()->loader()->activeDocumentLoader())
1010 return WebHistoryItem(); 1009 return WebHistoryItem();
1011 1010
1012 // If we are still loading, then we don't want to clobber the current 1011 // If we are still loading, then we don't want to clobber the current
1013 // history item as this could cause us to lose the scroll position and 1012 // history item as this could cause us to lose the scroll position and
1014 // document state. However, it is OK for new navigations. 1013 // document state. However, it is OK for new navigations.
1015 // FIXME: Can we make this a plain old getter, instead of worrying about 1014 // FIXME: Can we make this a plain old getter, instead of worrying about
1016 // clobbering here? 1015 // clobbering here?
1017 if (!m_inSameDocumentHistoryLoad && (frame()->loader()->loadType() == FrameL oadTypeStandard 1016 if (!m_inSameDocumentHistoryLoad && (frame()->loader()->loadType() == FrameL oadTypeStandard
1018 || !frame()->loader()->activeDocumentLoader()->isLoadingInAPISense())) 1017 || !frame()->loader()->activeDocumentLoader()->isLoadingInAPISense()))
1019 frame()->loader()->history()->saveDocumentAndScrollState(); 1018 frame()->loader()->history()->saveDocumentAndScrollState(frame());
1020 1019
1021 if (HistoryItem* item = frame()->loader()->history()->provisionalItem()) 1020 if (RefPtr<HistoryItem> item = frame()->loader()->history()->provisionalItem ForExport(frame()))
1022 return WebHistoryItem(item); 1021 return WebHistoryItem(item);
1023 return WebHistoryItem(frame()->page()->mainFrame()->loader()->history()->cur rentItem()); 1022 return WebHistoryItem(frame()->loader()->history()->currentItemForExport(fra me()));
1024 } 1023 }
1025 1024
1026 void WebFrameImpl::enableViewSourceMode(bool enable) 1025 void WebFrameImpl::enableViewSourceMode(bool enable)
1027 { 1026 {
1028 if (frame()) 1027 if (frame())
1029 frame()->setInViewSourceMode(enable); 1028 frame()->setInViewSourceMode(enable);
1030 } 1029 }
1031 1030
1032 bool WebFrameImpl::isViewSourceModeEnabled() const 1031 bool WebFrameImpl::isViewSourceModeEnabled() const
1033 { 1032 {
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after
2186 // onload event handler. 2185 // onload event handler.
2187 // Because the event handler may set webframe->mFrame to null, 2186 // Because the event handler may set webframe->mFrame to null,
2188 // it is necessary to check the value after calling init() and 2187 // it is necessary to check the value after calling init() and
2189 // return without loading URL. 2188 // return without loading URL.
2190 // NOTE: m_client will be null if this frame has been detached. 2189 // NOTE: m_client will be null if this frame has been detached.
2191 // (b:791612) 2190 // (b:791612)
2192 childFrame->init(); // create an empty document 2191 childFrame->init(); // create an empty document
2193 if (!childFrame->tree()->parent()) 2192 if (!childFrame->tree()->parent())
2194 return 0; 2193 return 0;
2195 2194
2196 HistoryItem* parentItem = frame()->loader()->history()->currentItem(); 2195 HistoryItem* parentItem = frame()->loader()->history()->currentItem(frame()) ;
2197 HistoryItem* childItem = 0; 2196 HistoryItem* childItem = 0;
2198 // If we're moving in the back/forward list, we might want to replace the co ntent 2197 // If we're moving in the back/forward list, we might want to replace the co ntent
2199 // of this child frame with whatever was there at that point. 2198 // of this child frame with whatever was there at that point.
2200 if (parentItem && parentItem->children().size() && isBackForwardLoadType(fra me()->loader()->loadType()) && !frame()->document()->loadEventFinished()) 2199 if (parentItem && isBackForwardLoadType(frame()->loader()->loadType()) && !f rame()->document()->loadEventFinished())
2201 childItem = parentItem->childItemWithTarget(childFrame->tree()->uniqueNa me()); 2200 childItem = frame()->loader()->history()->currentItem(childFrame.get());
2202 2201
2203 if (childItem) 2202 if (childItem)
2204 childFrame->loader()->loadHistoryItem(childItem); 2203 childFrame->loader()->loadHistoryItem(childItem);
2205 else 2204 else
2206 childFrame->loader()->load(FrameLoadRequest(0, request.resourceRequest() , "_self")); 2205 childFrame->loader()->load(FrameLoadRequest(0, request.resourceRequest() , "_self"));
2207 2206
2208 // A synchronous navigation (about:blank) would have already processed 2207 // A synchronous navigation (about:blank) would have already processed
2209 // onload, so it is possible for the frame to have already been destroyed by 2208 // onload, so it is possible for the frame to have already been destroyed by
2210 // script in the page. 2209 // script in the page.
2211 // NOTE: m_client will be null if this frame has been detached. 2210 // NOTE: m_client will be null if this frame has been detached.
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 2514
2516 // There is a possibility that the frame being detached was the only 2515 // There is a possibility that the frame being detached was the only
2517 // pending one. We need to make sure final replies can be sent. 2516 // pending one. We need to make sure final replies can be sent.
2518 flushCurrentScopingEffort(m_findRequestIdentifier); 2517 flushCurrentScopingEffort(m_findRequestIdentifier);
2519 2518
2520 cancelPendingScopingEffort(); 2519 cancelPendingScopingEffort();
2521 } 2520 }
2522 } 2521 }
2523 2522
2524 } // namespace WebKit 2523 } // namespace WebKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698