Changeset 49012 in webkit
- Timestamp:
- Oct 2, 2009 12:57:48 AM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r49011 r49012 1 2009-10-01 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Darin Adler. 4 5 Move RedirectScheduler to its own file 6 https://bugs.webkit.org/show_bug.cgi?id=29952 7 8 This change is purely code motion. 9 10 No behavior change. 11 12 * GNUmakefile.am: 13 * WebCore.gypi: 14 * WebCore.pro: 15 * WebCore.vcproj/WebCore.vcproj: 16 * WebCore.xcodeproj/project.pbxproj: 17 * WebCoreSources.bkl: 18 * loader/FrameLoader.cpp: 19 * loader/FrameLoader.h: 20 * loader/RedirectScheduler.cpp: Added. 21 (WebCore::ScheduledRedirection::): 22 (WebCore::ScheduledRedirection::ScheduledRedirection): 23 (WebCore::RedirectScheduler::RedirectScheduler): 24 (WebCore::RedirectScheduler::~RedirectScheduler): 25 (WebCore::RedirectScheduler::redirectScheduledDuringLoad): 26 (WebCore::RedirectScheduler::clear): 27 (WebCore::RedirectScheduler::scheduleRedirect): 28 (WebCore::RedirectScheduler::mustLockBackForwardList): 29 (WebCore::RedirectScheduler::scheduleLocationChange): 30 (WebCore::RedirectScheduler::scheduleFormSubmission): 31 (WebCore::RedirectScheduler::scheduleRefresh): 32 (WebCore::RedirectScheduler::locationChangePending): 33 (WebCore::RedirectScheduler::scheduleHistoryNavigation): 34 (WebCore::RedirectScheduler::timerFired): 35 (WebCore::RedirectScheduler::schedule): 36 (WebCore::RedirectScheduler::startTimer): 37 (WebCore::RedirectScheduler::cancel): 38 * loader/RedirectScheduler.h: Added. 39 1 40 2009-10-02 Dave MacLachlan <dmaclach@gmail.com> 2 41 … … 98 137 * WebCore.xcodeproj/project.pbxproj: 99 138 100 2009- 10-01Adam Barth <abarth@webkit.org>139 2009-09-30 Adam Barth <abarth@webkit.org> 101 140 102 141 Reviewed by Darin Adler. -
trunk/WebCore/GNUmakefile.am
r48963 r49012 1245 1245 WebCore/loader/ProgressTracker.cpp \ 1246 1246 WebCore/loader/ProgressTracker.h \ 1247 WebCore/loader/RedirectScheduler.cpp \ 1248 WebCore/loader/RedirectScheduler.h \ 1247 1249 WebCore/loader/Request.cpp \ 1248 1250 WebCore/loader/Request.h \ -
trunk/WebCore/WebCore.gypi
r48978 r49012 1629 1629 'loader/ProgressTracker.cpp', 1630 1630 'loader/ProgressTracker.h', 1631 'loader/RedirectScheduler.cpp', 1632 'loader/RedirectScheduler.h', 1631 1633 'loader/Request.cpp', 1632 1634 'loader/Request.h', -
trunk/WebCore/WebCore.pro
r48974 r49012 1108 1108 loader/PluginDocument.cpp \ 1109 1109 loader/ProgressTracker.cpp \ 1110 loader/RedirectScheduler.cpp \ 1110 1111 loader/Request.cpp \ 1111 1112 loader/ResourceLoader.cpp \ -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r48989 r49012 17447 17447 <File 17448 17448 RelativePath="..\loader\ProgressTracker.h" 17449 > 17450 </File> 17451 <File 17452 RelativePath="..\loader\RedirectScheduler.cpp" 17453 > 17454 </File> 17455 <File 17456 RelativePath="..\loader\RedirectScheduler.h" 17449 17457 > 17450 17458 </File> -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r48995 r49012 2345 2345 93F9B7A10BA6032600854064 /* JSCDATASection.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F9B79F0BA6032600854064 /* JSCDATASection.h */; }; 2346 2346 93FDAFCA0B11307400E2746F /* EditorInsertAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 93FDAFC90B11307400E2746F /* EditorInsertAction.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2347 979F43D31075E44A0000F83B /* RedirectScheduler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 979F43D11075E44A0000F83B /* RedirectScheduler.cpp */; }; 2348 979F43D41075E44A0000F83B /* RedirectScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 979F43D21075E44A0000F83B /* RedirectScheduler.h */; }; 2347 2349 97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97DD4D840FDF4D6D00ECF9A4 /* XSSAuditor.cpp */; }; 2348 2350 97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */ = {isa = PBXBuildFile; fileRef = 97DD4D850FDF4D6E00ECF9A4 /* XSSAuditor.h */; }; … … 7523 7525 93F9B79F0BA6032600854064 /* JSCDATASection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCDATASection.h; sourceTree = "<group>"; }; 7524 7526 93FDAFC90B11307400E2746F /* EditorInsertAction.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EditorInsertAction.h; sourceTree = "<group>"; }; 7527 979F43D11075E44A0000F83B /* RedirectScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RedirectScheduler.cpp; sourceTree = "<group>"; }; 7528 979F43D21075E44A0000F83B /* RedirectScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RedirectScheduler.h; sourceTree = "<group>"; }; 7525 7529 97DD4D840FDF4D6D00ECF9A4 /* XSSAuditor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XSSAuditor.cpp; sourceTree = "<group>"; }; 7526 7530 97DD4D850FDF4D6E00ECF9A4 /* XSSAuditor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XSSAuditor.h; sourceTree = "<group>"; }; … … 14562 14566 1A2A68210B5BEDE70002A480 /* ProgressTracker.cpp */, 14563 14567 1A2A68220B5BEDE70002A480 /* ProgressTracker.h */, 14568 979F43D11075E44A0000F83B /* RedirectScheduler.cpp */, 14569 979F43D21075E44A0000F83B /* RedirectScheduler.h */, 14564 14570 BCB16C150979C3BD00467741 /* Request.cpp */, 14565 14571 BCB16C160979C3BD00467741 /* Request.h */, … … 17926 17932 5DB1BC6A10715A6400EFAA49 /* TransformSource.h in Headers */, 17927 17933 930FC68A1072B9280045293E /* TextRenderingMode.h in Headers */, 17934 979F43D41075E44A0000F83B /* RedirectScheduler.h in Headers */, 17928 17935 ); 17929 17936 runOnlyForDeploymentPostprocessing = 0; … … 20042 20049 BCACF3BC1072921A00C0C8A3 /* UserContentURLPattern.cpp in Sources */, 20043 20050 5DB1BC6B10715A6400EFAA49 /* TransformSourceLibxslt.cpp in Sources */, 20051 979F43D31075E44A0000F83B /* RedirectScheduler.cpp in Sources */, 20044 20052 ); 20045 20053 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/WebCoreSources.bkl
r48937 r49012 729 729 loader/PluginDocument.cpp 730 730 loader/ProgressTracker.cpp 731 loader/RedirectScheduler.cpp 731 732 loader/Request.cpp 732 733 loader/ResourceLoader.cpp -
trunk/WebCore/loader/FrameLoader.cpp
r48994 r49012 124 124 using namespace HTMLNames; 125 125 126 struct ScheduledRedirection {127 enum Type { redirection, locationChange, historyNavigation, formSubmission };128 129 const Type type;130 const double delay;131 const String url;132 const String referrer;133 const FrameLoadRequest frameRequest;134 const RefPtr<Event> event;135 const RefPtr<FormState> formState;136 const int historySteps;137 const bool lockHistory;138 const bool lockBackForwardList;139 const bool wasUserGesture;140 const bool wasRefresh;141 const bool wasDuringLoad;142 bool toldClient;143 144 ScheduledRedirection(double delay, const String& url, bool lockHistory, bool lockBackForwardList, bool wasUserGesture, bool refresh)145 : type(redirection)146 , delay(delay)147 , url(url)148 , historySteps(0)149 , lockHistory(lockHistory)150 , lockBackForwardList(lockBackForwardList)151 , wasUserGesture(wasUserGesture)152 , wasRefresh(refresh)153 , wasDuringLoad(false)154 , toldClient(false)155 {156 ASSERT(!url.isEmpty());157 }158 159 ScheduledRedirection(const String& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool wasUserGesture, bool refresh, bool duringLoad)160 : type(locationChange)161 , delay(0)162 , url(url)163 , referrer(referrer)164 , historySteps(0)165 , lockHistory(lockHistory)166 , lockBackForwardList(lockBackForwardList)167 , wasUserGesture(wasUserGesture)168 , wasRefresh(refresh)169 , wasDuringLoad(duringLoad)170 , toldClient(false)171 {172 ASSERT(!url.isEmpty());173 }174 175 explicit ScheduledRedirection(int historyNavigationSteps)176 : type(historyNavigation)177 , delay(0)178 , historySteps(historyNavigationSteps)179 , lockHistory(false)180 , lockBackForwardList(false)181 , wasUserGesture(false)182 , wasRefresh(false)183 , wasDuringLoad(false)184 , toldClient(false)185 {186 }187 188 ScheduledRedirection(const FrameLoadRequest& frameRequest,189 bool lockHistory, bool lockBackForwardList, PassRefPtr<Event> event, PassRefPtr<FormState> formState,190 bool duringLoad)191 : type(formSubmission)192 , delay(0)193 , frameRequest(frameRequest)194 , event(event)195 , formState(formState)196 , historySteps(0)197 , lockHistory(lockHistory)198 , lockBackForwardList(lockBackForwardList)199 , wasUserGesture(false)200 , wasRefresh(false)201 , wasDuringLoad(duringLoad)202 , toldClient(false)203 {204 ASSERT(!frameRequest.isEmpty());205 ASSERT(this->formState);206 }207 };208 209 RedirectScheduler::RedirectScheduler(Frame* frame)210 : m_frame(frame)211 , m_timer(this, &RedirectScheduler::timerFired)212 {213 }214 215 RedirectScheduler::~RedirectScheduler()216 {217 }218 219 bool RedirectScheduler::redirectScheduledDuringLoad()220 {221 return m_scheduledRedirection && m_scheduledRedirection->wasDuringLoad;222 }223 224 void RedirectScheduler::clear()225 {226 m_timer.stop();227 m_scheduledRedirection.clear();228 }229 230 126 #if ENABLE(XHTMLMP) 231 127 static const char defaultAcceptHeader[] = "application/xml,application/vnd.wap.xhtml+xml,application/xhtml+xml;profile='http://www.wapforum.org/xhtml',text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; … … 1375 1271 } 1376 1272 1377 void RedirectScheduler::scheduleRedirect(double delay, const String& url)1378 {1379 if (delay < 0 || delay > INT_MAX / 1000)1380 return;1381 1382 if (!m_frame->page())1383 return;1384 1385 if (url.isEmpty())1386 return;1387 1388 // We want a new history item if the refresh timeout is > 1 second.1389 if (!m_scheduledRedirection || delay <= m_scheduledRedirection->delay)1390 schedule(new ScheduledRedirection(delay, url, true, delay <= 1, false, false));1391 }1392 1393 bool RedirectScheduler::mustLockBackForwardList(Frame* targetFrame)1394 {1395 // Navigation of a subframe during loading of an ancestor frame does not create a new back/forward item.1396 // The definition of "during load" is any time before all handlers for the load event have been run.1397 // See https://bugs.webkit.org/show_bug.cgi?id=14957 for the original motivation for this.1398 1399 for (Frame* ancestor = targetFrame->tree()->parent(); ancestor; ancestor = ancestor->tree()->parent()) {1400 Document* document = ancestor->document();1401 if (!ancestor->loader()->isComplete() || document && document->processingLoadEvent())1402 return true;1403 }1404 return false;1405 }1406 1407 void RedirectScheduler::scheduleLocationChange(const String& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool wasUserGesture)1408 {1409 if (!m_frame->page())1410 return;1411 1412 if (url.isEmpty())1413 return;1414 1415 lockBackForwardList = lockBackForwardList || mustLockBackForwardList(m_frame);1416 1417 FrameLoader* loader = m_frame->loader();1418 1419 // If the URL we're going to navigate to is the same as the current one, except for the1420 // fragment part, we don't need to schedule the location change.1421 KURL parsedURL(ParsedURLString, url);1422 if (parsedURL.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(loader->url(), parsedURL)) {1423 loader->changeLocation(loader->completeURL(url), referrer, lockHistory, lockBackForwardList, wasUserGesture);1424 return;1425 }1426 1427 // Handle a location change of a page with no document as a special case.1428 // This may happen when a frame changes the location of another frame.1429 bool duringLoad = !loader->committedFirstRealDocumentLoad();1430 1431 schedule(new ScheduledRedirection(url, referrer, lockHistory, lockBackForwardList, wasUserGesture, false, duringLoad));1432 }1433 1434 void RedirectScheduler::scheduleFormSubmission(const FrameLoadRequest& frameRequest,1435 bool lockHistory, PassRefPtr<Event> event, PassRefPtr<FormState> formState)1436 {1437 ASSERT(m_frame->page());1438 ASSERT(!frameRequest.isEmpty());1439 1440 // FIXME: Do we need special handling for form submissions where the URL is the same1441 // as the current one except for the fragment part? See scheduleLocationChange above.1442 1443 // Handle a location change of a page with no document as a special case.1444 // This may happen when a frame changes the location of another frame.1445 bool duringLoad = !m_frame->loader()->committedFirstRealDocumentLoad();1446 1447 schedule(new ScheduledRedirection(frameRequest, lockHistory, mustLockBackForwardList(m_frame), event, formState, duringLoad));1448 }1449 1450 void RedirectScheduler::scheduleRefresh(bool wasUserGesture)1451 {1452 if (!m_frame->page())1453 return;1454 1455 const KURL& url = m_frame->loader()->url();1456 1457 if (url.isEmpty())1458 return;1459 1460 schedule(new ScheduledRedirection(url.string(), m_frame->loader()->outgoingReferrer(), true, true, wasUserGesture, true, false));1461 }1462 1463 bool RedirectScheduler::locationChangePending()1464 {1465 if (!m_scheduledRedirection)1466 return false;1467 1468 switch (m_scheduledRedirection->type) {1469 case ScheduledRedirection::redirection:1470 return false;1471 case ScheduledRedirection::historyNavigation:1472 case ScheduledRedirection::locationChange:1473 case ScheduledRedirection::formSubmission:1474 return true;1475 }1476 ASSERT_NOT_REACHED();1477 return false;1478 }1479 1480 void RedirectScheduler::scheduleHistoryNavigation(int steps)1481 {1482 if (!m_frame->page())1483 return;1484 1485 schedule(new ScheduledRedirection(steps));1486 }1487 1488 1273 void FrameLoader::goBackOrForward(int distance) 1489 1274 { … … 1514 1299 if (item) 1515 1300 page->goToItem(item, FrameLoadTypeIndexedBackForward); 1516 }1517 1518 void RedirectScheduler::timerFired(Timer<RedirectScheduler>*)1519 {1520 ASSERT(m_frame->page());1521 1522 if (m_frame->page()->defersLoading())1523 return;1524 1525 OwnPtr<ScheduledRedirection> redirection(m_scheduledRedirection.release());1526 FrameLoader* loader = m_frame->loader();1527 1528 switch (redirection->type) {1529 case ScheduledRedirection::redirection:1530 case ScheduledRedirection::locationChange:1531 loader->changeLocation(KURL(ParsedURLString, redirection->url), redirection->referrer,1532 redirection->lockHistory, redirection->lockBackForwardList, redirection->wasUserGesture, redirection->wasRefresh);1533 return;1534 case ScheduledRedirection::historyNavigation:1535 if (redirection->historySteps == 0) {1536 // Special case for go(0) from a frame -> reload only the frame1537 loader->urlSelected(loader->url(), "", 0, redirection->lockHistory, redirection->lockBackForwardList, redirection->wasUserGesture);1538 return;1539 }1540 // go(i!=0) from a frame navigates into the history of the frame only,1541 // in both IE and NS (but not in Mozilla). We can't easily do that.1542 if (loader->canGoBackOrForward(redirection->historySteps))1543 loader->goBackOrForward(redirection->historySteps);1544 return;1545 case ScheduledRedirection::formSubmission:1546 // The submitForm function will find a target frame before using the redirection timer.1547 // Now that the timer has fired, we need to repeat the security check which normally is done when1548 // selecting a target, in case conditions have changed. Other code paths avoid this by targeting1549 // without leaving a time window. If we fail the check just silently drop the form submission.1550 if (!redirection->formState->sourceFrame()->loader()->shouldAllowNavigation(m_frame))1551 return;1552 loader->loadFrameRequest(redirection->frameRequest, redirection->lockHistory, redirection->lockBackForwardList,1553 redirection->event, redirection->formState);1554 return;1555 }1556 1557 ASSERT_NOT_REACHED();1558 1301 } 1559 1302 … … 2157 1900 { 2158 1901 return m_isComplete; 2159 }2160 2161 void RedirectScheduler::schedule(PassOwnPtr<ScheduledRedirection> redirection)2162 {2163 ASSERT(m_frame->page());2164 FrameLoader* loader = m_frame->loader();2165 2166 // If a redirect was scheduled during a load, then stop the current load.2167 // Otherwise when the current load transitions from a provisional to a2168 // committed state, pending redirects may be cancelled.2169 if (redirection->wasDuringLoad) {2170 if (DocumentLoader* provisionalDocumentLoader = loader->provisionalDocumentLoader())2171 provisionalDocumentLoader->stopLoading();2172 loader->stopLoading(UnloadEventPolicyUnloadAndPageHide);2173 }2174 2175 cancel();2176 m_scheduledRedirection = redirection;2177 if (!loader->isComplete() && m_scheduledRedirection->type != ScheduledRedirection::redirection)2178 loader->completed();2179 startTimer();2180 }2181 2182 void RedirectScheduler::startTimer()2183 {2184 if (!m_scheduledRedirection)2185 return;2186 2187 ASSERT(m_frame->page());2188 2189 FrameLoader* loader = m_frame->loader();2190 2191 if (m_timer.isActive())2192 return;2193 2194 if (m_scheduledRedirection->type == ScheduledRedirection::redirection && !loader->allAncestorsAreComplete())2195 return;2196 2197 m_timer.startOneShot(m_scheduledRedirection->delay);2198 2199 switch (m_scheduledRedirection->type) {2200 case ScheduledRedirection::locationChange:2201 case ScheduledRedirection::redirection:2202 if (m_scheduledRedirection->toldClient)2203 return;2204 m_scheduledRedirection->toldClient = true;2205 loader->clientRedirected(KURL(ParsedURLString, m_scheduledRedirection->url),2206 m_scheduledRedirection->delay,2207 currentTime() + m_timer.nextFireInterval(),2208 m_scheduledRedirection->lockBackForwardList);2209 return;2210 case ScheduledRedirection::formSubmission:2211 // FIXME: It would make sense to report form submissions as client redirects too.2212 // But we didn't do that in the past when form submission used a separate delay2213 // mechanism, so doing it will be a behavior change.2214 return;2215 case ScheduledRedirection::historyNavigation:2216 // Don't report history navigations.2217 return;2218 }2219 ASSERT_NOT_REACHED();2220 }2221 2222 void RedirectScheduler::cancel(bool newLoadInProgress)2223 {2224 m_timer.stop();2225 2226 OwnPtr<ScheduledRedirection> redirection(m_scheduledRedirection.release());2227 if (redirection && redirection->toldClient)2228 m_frame->loader()->clientRedirectCancelledOrFinished(newLoadInProgress);2229 1902 } 2230 1903 -
trunk/WebCore/loader/FrameLoader.h
r48994 r49012 33 33 #include "CachePolicy.h" 34 34 #include "FrameLoaderTypes.h" 35 #include "RedirectScheduler.h" 35 36 #include "ResourceRequest.h" 36 37 #include "ThreadableLoader.h" … … 73 74 74 75 struct FrameLoadRequest; 75 struct ScheduledRedirection;76 76 struct WindowFeatures; 77 77 … … 111 111 ContentPolicyDecisionFunction m_contentFunction; 112 112 void* m_argument; 113 };114 115 class RedirectScheduler : public Noncopyable {116 public:117 RedirectScheduler(Frame*);118 ~RedirectScheduler();119 120 bool redirectScheduledDuringLoad();121 bool locationChangePending();122 123 void scheduleRedirect(double delay, const String& url);124 void scheduleLocationChange(const String& url, const String& referrer, bool lockHistory = true, bool lockBackForwardList = true, bool userGesture = false);125 void scheduleFormSubmission(const FrameLoadRequest&, bool lockHistory, PassRefPtr<Event>, PassRefPtr<FormState>);126 void scheduleRefresh(bool userGesture = false);127 void scheduleHistoryNavigation(int steps);128 129 void startTimer();130 131 void cancel(bool newLoadInProgress = false);132 void clear();133 134 private:135 void timerFired(Timer<RedirectScheduler>*);136 void schedule(PassOwnPtr<ScheduledRedirection> redirection);137 138 static bool mustLockBackForwardList(Frame* targetFrame);139 140 Frame* m_frame;141 Timer<RedirectScheduler> m_timer;142 OwnPtr<ScheduledRedirection> m_scheduledRedirection;143 113 }; 144 114
Note: See TracChangeset
for help on using the changeset viewer.