OLD | NEW |
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 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 4 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 String target; | 137 String target; |
138 String contentType; | 138 String contentType; |
139 String boundary; | 139 String boundary; |
140 RefPtr<Event> event; | 140 RefPtr<Event> event; |
141 bool lockHistory; | 141 bool lockHistory; |
142 bool lockBackForwardList; | 142 bool lockBackForwardList; |
143 }; | 143 }; |
144 | 144 |
145 struct ScheduledRedirection { | 145 struct ScheduledRedirection { |
146 enum Type { redirection, locationChange, historyNavigation, locationChangeDu
ringLoad }; | 146 enum Type { redirection, locationChange, historyNavigation, locationChangeDu
ringLoad }; |
147 Type type; | 147 |
148 double delay; | 148 const Type type; |
149 String url; | 149 const double delay; |
150 String referrer; | 150 const String url; |
151 int historySteps; | 151 const String referrer; |
152 bool lockHistory; | 152 const int historySteps; |
153 bool lockBackForwardList; | 153 const bool lockHistory; |
154 bool wasUserGesture; | 154 const bool lockBackForwardList; |
155 bool wasRefresh; | 155 const bool wasUserGesture; |
| 156 const bool wasRefresh; |
156 | 157 |
157 ScheduledRedirection(double delay, const String& url, bool lockHistory, bool
lockBackForwardList, bool wasUserGesture, bool refresh) | 158 ScheduledRedirection(double delay, const String& url, bool lockHistory, bool
lockBackForwardList, bool wasUserGesture, bool refresh) |
158 : type(redirection) | 159 : type(redirection) |
159 , delay(delay) | 160 , delay(delay) |
160 , url(url) | 161 , url(url) |
161 , historySteps(0) | 162 , historySteps(0) |
162 , lockHistory(lockHistory) | 163 , lockHistory(lockHistory) |
163 , lockBackForwardList(lockBackForwardList) | 164 , lockBackForwardList(lockBackForwardList) |
164 , wasUserGesture(wasUserGesture) | 165 , wasUserGesture(wasUserGesture) |
165 , wasRefresh(refresh) | 166 , wasRefresh(refresh) |
166 { | 167 { |
| 168 ASSERT(!url.isEmpty()); |
167 } | 169 } |
168 | 170 |
169 ScheduledRedirection(Type locationChangeType, const String& url, const Strin
g& referrer, bool lockHistory, bool lockBackForwardList, bool wasUserGesture, bo
ol refresh) | 171 ScheduledRedirection(Type locationChangeType, const String& url, const Strin
g& referrer, bool lockHistory, bool lockBackForwardList, bool wasUserGesture, bo
ol refresh) |
170 : type(locationChangeType) | 172 : type(locationChangeType) |
171 , delay(0) | 173 , delay(0) |
172 , url(url) | 174 , url(url) |
173 , referrer(referrer) | 175 , referrer(referrer) |
174 , historySteps(0) | 176 , historySteps(0) |
175 , lockHistory(lockHistory) | 177 , lockHistory(lockHistory) |
176 , lockBackForwardList(lockBackForwardList) | 178 , lockBackForwardList(lockBackForwardList) |
177 , wasUserGesture(wasUserGesture) | 179 , wasUserGesture(wasUserGesture) |
178 , wasRefresh(refresh) | 180 , wasRefresh(refresh) |
179 { | 181 { |
| 182 ASSERT(locationChangeType == locationChange || locationChangeType == loc
ationChangeDuringLoad); |
| 183 ASSERT(!url.isEmpty()); |
180 } | 184 } |
181 | 185 |
182 explicit ScheduledRedirection(int historyNavigationSteps) | 186 explicit ScheduledRedirection(int historyNavigationSteps) |
183 : type(historyNavigation) | 187 : type(historyNavigation) |
184 , delay(0) | 188 , delay(0) |
185 , historySteps(historyNavigationSteps) | 189 , historySteps(historyNavigationSteps) |
186 , lockHistory(false) | 190 , lockHistory(false) |
| 191 , lockBackForwardList(false) |
187 , wasUserGesture(false) | 192 , wasUserGesture(false) |
188 , wasRefresh(false) | 193 , wasRefresh(false) |
189 { | 194 { |
190 } | 195 } |
191 }; | 196 }; |
192 | 197 |
193 static double storedTimeOfLastCompletedLoad; | 198 static double storedTimeOfLastCompletedLoad; |
194 static FrameLoader::LocalLoadPolicy localLoadPolicy = FrameLoader::AllowLocalLoa
dsForLocalOnly; | 199 static FrameLoader::LocalLoadPolicy localLoadPolicy = FrameLoader::AllowLocalLoa
dsForLocalOnly; |
195 | 200 |
196 bool isBackForwardLoadType(FrameLoadType type) | 201 bool isBackForwardLoadType(FrameLoadType type) |
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 } | 1321 } |
1317 | 1322 |
1318 void FrameLoader::scheduleHTTPRedirection(double delay, const String& url) | 1323 void FrameLoader::scheduleHTTPRedirection(double delay, const String& url) |
1319 { | 1324 { |
1320 if (delay < 0 || delay > INT_MAX / 1000) | 1325 if (delay < 0 || delay > INT_MAX / 1000) |
1321 return; | 1326 return; |
1322 | 1327 |
1323 if (!m_frame->page()) | 1328 if (!m_frame->page()) |
1324 return; | 1329 return; |
1325 | 1330 |
| 1331 if (url.isEmpty()) |
| 1332 return; |
| 1333 |
1326 // We want a new history item if the refresh timeout is > 1 second. | 1334 // We want a new history item if the refresh timeout is > 1 second. |
1327 if (!m_scheduledRedirection || delay <= m_scheduledRedirection->delay) | 1335 if (!m_scheduledRedirection || delay <= m_scheduledRedirection->delay) |
1328 scheduleRedirection(new ScheduledRedirection(delay, url, true, delay <=
1, false, false)); | 1336 scheduleRedirection(new ScheduledRedirection(delay, url, true, delay <=
1, false, false)); |
1329 } | 1337 } |
1330 | 1338 |
1331 void FrameLoader::scheduleLocationChange(const String& url, const String& referr
er, bool lockHistory, bool lockBackForwardList, bool wasUserGesture) | 1339 void FrameLoader::scheduleLocationChange(const String& url, const String& referr
er, bool lockHistory, bool lockBackForwardList, bool wasUserGesture) |
1332 { | 1340 { |
1333 if (!m_frame->page()) | 1341 if (!m_frame->page()) |
1334 return; | 1342 return; |
1335 | 1343 |
| 1344 if (url.isEmpty()) |
| 1345 return; |
| 1346 |
1336 // If the URL we're going to navigate to is the same as the current one, exc
ept for the | 1347 // If the URL we're going to navigate to is the same as the current one, exc
ept for the |
1337 // fragment part, we don't need to schedule the location change. | 1348 // fragment part, we don't need to schedule the location change. |
1338 KURL parsedURL(url); | 1349 KURL parsedURL(url); |
1339 if (parsedURL.hasRef() && equalIgnoringRef(m_URL, parsedURL)) { | 1350 if (parsedURL.hasRef() && equalIgnoringRef(m_URL, parsedURL)) { |
1340 changeLocation(url, referrer, lockHistory, lockBackForwardList, wasUserG
esture); | 1351 changeLocation(url, referrer, lockHistory, lockBackForwardList, wasUserG
esture); |
1341 return; | 1352 return; |
1342 } | 1353 } |
1343 | 1354 |
1344 // Handle a location change of a page with no document as a special case. | 1355 // Handle a location change of a page with no document as a special case. |
1345 // This may happen when a frame changes the location of another frame. | 1356 // This may happen when a frame changes the location of another frame. |
(...skipping 11 matching lines...) Expand all Loading... |
1357 ScheduledRedirection::Type type = duringLoad | 1368 ScheduledRedirection::Type type = duringLoad |
1358 ? ScheduledRedirection::locationChangeDuringLoad : ScheduledRedirection:
:locationChange; | 1369 ? ScheduledRedirection::locationChangeDuringLoad : ScheduledRedirection:
:locationChange; |
1359 scheduleRedirection(new ScheduledRedirection(type, url, referrer, lockHistor
y, lockBackForwardList, wasUserGesture, false)); | 1370 scheduleRedirection(new ScheduledRedirection(type, url, referrer, lockHistor
y, lockBackForwardList, wasUserGesture, false)); |
1360 } | 1371 } |
1361 | 1372 |
1362 void FrameLoader::scheduleRefresh(bool wasUserGesture) | 1373 void FrameLoader::scheduleRefresh(bool wasUserGesture) |
1363 { | 1374 { |
1364 if (!m_frame->page()) | 1375 if (!m_frame->page()) |
1365 return; | 1376 return; |
1366 | 1377 |
| 1378 if (m_URL.isEmpty()) |
| 1379 return; |
| 1380 |
1367 ScheduledRedirection::Type type = ScheduledRedirection::locationChange; | 1381 ScheduledRedirection::Type type = ScheduledRedirection::locationChange; |
1368 scheduleRedirection(new ScheduledRedirection(type, m_URL.string(), m_outgoin
gReferrer, true, true, wasUserGesture, true)); | 1382 scheduleRedirection(new ScheduledRedirection(type, m_URL.string(), m_outgoin
gReferrer, true, true, wasUserGesture, true)); |
1369 } | 1383 } |
1370 | 1384 |
1371 bool FrameLoader::isLocationChange(const ScheduledRedirection& redirection) | 1385 bool FrameLoader::isLocationChange(const ScheduledRedirection& redirection) |
1372 { | 1386 { |
1373 switch (redirection.type) { | 1387 switch (redirection.type) { |
1374 case ScheduledRedirection::redirection: | 1388 case ScheduledRedirection::redirection: |
1375 return false; | 1389 return false; |
1376 case ScheduledRedirection::historyNavigation: | 1390 case ScheduledRedirection::historyNavigation: |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1468 | 1482 |
1469 /* | 1483 /* |
1470 In the case of saving state about a page with frames, we store a tree of ite
ms that mirrors the frame tree. | 1484 In the case of saving state about a page with frames, we store a tree of ite
ms that mirrors the frame tree. |
1471 The item that was the target of the user's navigation is designated as the "
targetItem". | 1485 The item that was the target of the user's navigation is designated as the "
targetItem". |
1472 When this method is called with doClip=YES we're able to create the whole tr
ee except for the target's children, | 1486 When this method is called with doClip=YES we're able to create the whole tr
ee except for the target's children, |
1473 which will be loaded in the future. That part of the tree will be filled ou
t as the child loads are committed. | 1487 which will be loaded in the future. That part of the tree will be filled ou
t as the child loads are committed. |
1474 */ | 1488 */ |
1475 void FrameLoader::loadURLIntoChildFrame(const KURL& url, const String& referer,
Frame* childFrame) | 1489 void FrameLoader::loadURLIntoChildFrame(const KURL& url, const String& referer,
Frame* childFrame) |
1476 { | 1490 { |
1477 ASSERT(childFrame); | 1491 ASSERT(childFrame); |
| 1492 |
1478 HistoryItem* parentItem = currentHistoryItem(); | 1493 HistoryItem* parentItem = currentHistoryItem(); |
1479 FrameLoadType loadType = this->loadType(); | 1494 FrameLoadType loadType = this->loadType(); |
1480 FrameLoadType childLoadType = FrameLoadTypeRedirectWithLockedBackForwardList
; | 1495 FrameLoadType childLoadType = FrameLoadTypeRedirectWithLockedBackForwardList
; |
1481 | 1496 |
1482 KURL workingURL = url; | 1497 KURL workingURL = url; |
1483 | 1498 |
1484 // If we're moving in the backforward list, we might want to replace the con
tent | 1499 // If we're moving in the back/forward list, we might want to replace the co
ntent |
1485 // of this child frame with whatever was there at that point. | 1500 // of this child frame with whatever was there at that point. |
1486 if (parentItem && parentItem->children().size() && isBackForwardLoadType(loa
dType)) { | 1501 if (parentItem && parentItem->children().size() && isBackForwardLoadType(loa
dType)) { |
1487 HistoryItem* childItem = parentItem->childItemWithName(childFrame->tree(
)->name()); | 1502 HistoryItem* childItem = parentItem->childItemWithName(childFrame->tree(
)->name()); |
1488 if (childItem) { | 1503 if (childItem) { |
1489 // Use the original URL to ensure we get all the side-effects, such
as | 1504 // Use the original URL to ensure we get all the side-effects, such
as |
1490 // onLoad handlers, of any redirects that happened. An example of wh
ere | 1505 // onLoad handlers, of any redirects that happened. An example of wh
ere |
1491 // this is needed is Radar 3213556. | 1506 // this is needed is Radar 3213556. |
1492 workingURL = KURL(childItem->originalURLString()); | 1507 workingURL = KURL(childItem->originalURLString()); |
1493 childLoadType = loadType; | 1508 childLoadType = loadType; |
1494 childFrame->loader()->setProvisionalHistoryItem(childItem); | 1509 childFrame->loader()->setProvisionalHistoryItem(childItem); |
(...skipping 3781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5276 m_client->dispatchDidLoadResourceFromMemoryCache(m_documentLoader.get(),
request, resource->response(), resource->encodedSize()); | 5291 m_client->dispatchDidLoadResourceFromMemoryCache(m_documentLoader.get(),
request, resource->response(), resource->encodedSize()); |
5277 } | 5292 } |
5278 } | 5293 } |
5279 | 5294 |
5280 bool FrameLoaderClient::hasHTMLView() const | 5295 bool FrameLoaderClient::hasHTMLView() const |
5281 { | 5296 { |
5282 return true; | 5297 return true; |
5283 } | 5298 } |
5284 | 5299 |
5285 } // namespace WebCore | 5300 } // namespace WebCore |
OLD | NEW |