OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
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 * Copyright (C) 2008 Alp Toker <alp@atoker.com> | 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> |
6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. |
7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> | 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> |
8 * Copyright (C) 2011 Google Inc. All rights reserved. | 8 * Copyright (C) 2011 Google Inc. All rights reserved. |
9 * | 9 * |
10 * Redistribution and use in source and binary forms, with or without | 10 * Redistribution and use in source and binary forms, with or without |
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 if (Frame* parent = m_frame->tree()->parent()) | 1118 if (Frame* parent = m_frame->tree()->parent()) |
1119 loader->setOverrideEncoding(parent->loader()->documentLoader()->override
Encoding()); | 1119 loader->setOverrideEncoding(parent->loader()->documentLoader()->override
Encoding()); |
1120 else if (!overrideEncoding.isEmpty()) | 1120 else if (!overrideEncoding.isEmpty()) |
1121 loader->setOverrideEncoding(overrideEncoding); | 1121 loader->setOverrideEncoding(overrideEncoding); |
1122 else if (m_documentLoader) | 1122 else if (m_documentLoader) |
1123 loader->setOverrideEncoding(m_documentLoader->overrideEncoding()); | 1123 loader->setOverrideEncoding(m_documentLoader->overrideEncoding()); |
1124 | 1124 |
1125 if (type == FrameLoadTypeRedirectWithLockedBackForwardList) | 1125 if (type == FrameLoadTypeRedirectWithLockedBackForwardList) |
1126 loader->setIsClientRedirect(true); | 1126 loader->setIsClientRedirect(true); |
1127 | 1127 |
1128 m_loadType = type; | |
1129 bool isFormSubmission = formState; | 1128 bool isFormSubmission = formState; |
1130 | 1129 |
1131 if (shouldPerformFragmentNavigation(isFormSubmission, request.httpMethod(),
type, request.url())) | 1130 if (shouldPerformFragmentNavigation(isFormSubmission, request.httpMethod(),
type, request.url())) |
1132 checkNavigationPolicyAndContinueFragmentScroll(action); | 1131 checkNavigationPolicyAndContinueFragmentScroll(action, type != FrameLoad
TypeRedirectWithLockedBackForwardList); |
1133 else { | 1132 else { |
1134 setPolicyDocumentLoader(loader.get()); | 1133 setPolicyDocumentLoader(loader.get()); |
1135 checkNavigationPolicyAndContinueLoad(formState); | 1134 checkNavigationPolicyAndContinueLoad(formState, type); |
1136 } | 1135 } |
1137 } | 1136 } |
1138 | 1137 |
1139 void FrameLoader::reportLocalLoadFailed(Frame* frame, const String& url) | 1138 void FrameLoader::reportLocalLoadFailed(Frame* frame, const String& url) |
1140 { | 1139 { |
1141 ASSERT(!url.isEmpty()); | 1140 ASSERT(!url.isEmpty()); |
1142 if (!frame) | 1141 if (!frame) |
1143 return; | 1142 return; |
1144 | 1143 |
1145 frame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLeve
l, "Not allowed to load local resource: " + url); | 1144 frame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLeve
l, "Not allowed to load local resource: " + url); |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1923 // status has changed, if there was a redirect. | 1922 // status has changed, if there was a redirect. |
1924 if (loader->isClientRedirect()) | 1923 if (loader->isClientRedirect()) |
1925 clientRedirectCancelledOrFinished(); | 1924 clientRedirectCancelledOrFinished(); |
1926 } | 1925 } |
1927 | 1926 |
1928 checkCompleted(); | 1927 checkCompleted(); |
1929 if (m_frame->page()) | 1928 if (m_frame->page()) |
1930 checkLoadComplete(); | 1929 checkLoadComplete(); |
1931 } | 1930 } |
1932 | 1931 |
1933 void FrameLoader::checkNavigationPolicyAndContinueFragmentScroll(const Navigatio
nAction& action) | 1932 void FrameLoader::checkNavigationPolicyAndContinueFragmentScroll(const Navigatio
nAction& action, bool isNewNavigation) |
1934 { | 1933 { |
1935 m_documentLoader->setTriggeringAction(action); | 1934 m_documentLoader->setTriggeringAction(action); |
1936 | 1935 |
1937 const ResourceRequest& request = action.resourceRequest(); | 1936 const ResourceRequest& request = action.resourceRequest(); |
1938 if (!m_documentLoader->shouldContinueForNavigationPolicy(request)) | 1937 if (!m_documentLoader->shouldContinueForNavigationPolicy(request)) |
1939 return; | 1938 return; |
1940 | 1939 |
1941 // If we have a provisional request for a different document, a fragment scr
oll should cancel it. | 1940 // If we have a provisional request for a different document, a fragment scr
oll should cancel it. |
1942 if (m_provisionalDocumentLoader && !equalIgnoringFragmentIdentifier(m_provis
ionalDocumentLoader->request().url(), request.url())) { | 1941 if (m_provisionalDocumentLoader && !equalIgnoringFragmentIdentifier(m_provis
ionalDocumentLoader->request().url(), request.url())) { |
1943 m_provisionalDocumentLoader->stopLoading(); | 1942 m_provisionalDocumentLoader->stopLoading(); |
1944 setProvisionalDocumentLoader(0); | 1943 setProvisionalDocumentLoader(0); |
1945 } | 1944 } |
1946 loadInSameDocument(request.url(), 0, m_loadType != FrameLoadTypeRedirectWith
LockedBackForwardList); | 1945 loadInSameDocument(request.url(), 0, isNewNavigation); |
1947 } | 1946 } |
1948 | 1947 |
1949 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S
tring& httpMethod, FrameLoadType loadType, const KURL& url) | 1948 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S
tring& httpMethod, FrameLoadType loadType, const KURL& url) |
1950 { | 1949 { |
1951 // We don't do this if we are submitting a form with method other than "GET"
, explicitly reloading, | 1950 // We don't do this if we are submitting a form with method other than "GET"
, explicitly reloading, |
1952 // currently displaying a frameset, or if the URL does not have a fragment. | 1951 // currently displaying a frameset, or if the URL does not have a fragment. |
1953 // These rules were originally based on what KHTML was doing in KHTMLPart::o
penURL. | 1952 // These rules were originally based on what KHTML was doing in KHTMLPart::o
penURL. |
1954 | 1953 |
1955 // FIXME: What about load types other than Standard and Reload? | 1954 // FIXME: What about load types other than Standard and Reload? |
1956 | 1955 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2033 | 2032 |
2034 if (!beforeUnloadEvent->defaultPrevented()) | 2033 if (!beforeUnloadEvent->defaultPrevented()) |
2035 document->defaultEventHandler(beforeUnloadEvent.get()); | 2034 document->defaultEventHandler(beforeUnloadEvent.get()); |
2036 if (beforeUnloadEvent->result().isNull()) | 2035 if (beforeUnloadEvent->result().isNull()) |
2037 return true; | 2036 return true; |
2038 | 2037 |
2039 String text = document->displayStringModifiedByEncoding(beforeUnloadEvent->r
esult()); | 2038 String text = document->displayStringModifiedByEncoding(beforeUnloadEvent->r
esult()); |
2040 return chrome.runBeforeUnloadConfirmPanel(text, m_frame); | 2039 return chrome.runBeforeUnloadConfirmPanel(text, m_frame); |
2041 } | 2040 } |
2042 | 2041 |
2043 void FrameLoader::checkNavigationPolicyAndContinueLoad(PassRefPtr<FormState> for
mState) | 2042 void FrameLoader::checkNavigationPolicyAndContinueLoad(PassRefPtr<FormState> for
mState, FrameLoadType type) |
2044 { | 2043 { |
2045 // If we loaded an alternate page to replace an unreachableURL, we'll get in
here with a | 2044 // If we loaded an alternate page to replace an unreachableURL, we'll get in
here with a |
2046 // nil policyDataSource because loading the alternate page will have passed | 2045 // nil policyDataSource because loading the alternate page will have passed |
2047 // through this method already, nested; otherwise, policyDataSource should s
till be set. | 2046 // through this method already, nested; otherwise, policyDataSource should s
till be set. |
2048 ASSERT(m_policyDocumentLoader || !m_provisionalDocumentLoader->unreachableUR
L().isEmpty()); | 2047 ASSERT(m_policyDocumentLoader || !m_provisionalDocumentLoader->unreachableUR
L().isEmpty()); |
2049 | 2048 |
2050 // stopAllLoaders can detach the Frame, so protect it. | 2049 // stopAllLoaders can detach the Frame, so protect it. |
2051 RefPtr<Frame> protect(m_frame); | 2050 RefPtr<Frame> protect(m_frame); |
2052 | 2051 |
2053 bool isTargetItem = history()->provisionalItem() ? history()->provisionalIte
m()->isTargetItem() : false; | 2052 bool isTargetItem = history()->provisionalItem() ? history()->provisionalIte
m()->isTargetItem() : false; |
(...skipping 19 matching lines...) Expand all Loading... |
2073 // If we were waiting for a client redirect, but the policy delegate dec
ided to ignore it, then we | 2072 // If we were waiting for a client redirect, but the policy delegate dec
ided to ignore it, then we |
2074 // need to report that the client redirect was cancelled. | 2073 // need to report that the client redirect was cancelled. |
2075 if (m_policyDocumentLoader->isClientRedirect()) | 2074 if (m_policyDocumentLoader->isClientRedirect()) |
2076 clientRedirectCancelledOrFinished(); | 2075 clientRedirectCancelledOrFinished(); |
2077 | 2076 |
2078 setPolicyDocumentLoader(0); | 2077 setPolicyDocumentLoader(0); |
2079 | 2078 |
2080 // If the navigation request came from the back/forward menu, and we pun
t on it, we have the | 2079 // If the navigation request came from the back/forward menu, and we pun
t on it, we have the |
2081 // problem that we have optimistically moved the b/f cursor already, so
move it back. For sanity, | 2080 // problem that we have optimistically moved the b/f cursor already, so
move it back. For sanity, |
2082 // we only do this when punting a navigation for the target frame or top
-level frame. | 2081 // we only do this when punting a navigation for the target frame or top
-level frame. |
2083 if ((isTargetItem || isLoadingMainFrame()) && isBackForwardLoadType(m_lo
adType)) { | 2082 if ((isTargetItem || isLoadingMainFrame()) && isBackForwardLoadType(type
)) { |
2084 if (Page* page = m_frame->page()) { | 2083 if (Page* page = m_frame->page()) { |
2085 Frame* mainFrame = page->mainFrame(); | 2084 Frame* mainFrame = page->mainFrame(); |
2086 if (HistoryItem* resetItem = mainFrame->loader()->history()->cur
rentItem()) | 2085 if (HistoryItem* resetItem = mainFrame->loader()->history()->cur
rentItem()) |
2087 page->backForward()->setCurrentItem(resetItem); | 2086 page->backForward()->setCurrentItem(resetItem); |
2088 } | 2087 } |
2089 } | 2088 } |
2090 return; | 2089 return; |
2091 } | 2090 } |
2092 | 2091 |
2093 // A new navigation is in progress, so don't clear the history's provisional
item. | 2092 // A new navigation is in progress, so don't clear the history's provisional
item. |
2094 stopAllLoaders(ShouldNotClearProvisionalItem); | 2093 stopAllLoaders(ShouldNotClearProvisionalItem); |
2095 | 2094 |
2096 // <rdar://problem/6250856> - In certain circumstances on pages with multipl
e frames, stopAllLoaders() | 2095 // <rdar://problem/6250856> - In certain circumstances on pages with multipl
e frames, stopAllLoaders() |
2097 // might detach the current FrameLoader, in which case we should bail on thi
s newly defunct load. | 2096 // might detach the current FrameLoader, in which case we should bail on thi
s newly defunct load. |
2098 if (!m_frame->page()) | 2097 if (!m_frame->page()) |
2099 return; | 2098 return; |
2100 | 2099 |
2101 if (Page* page = m_frame->page()) { | 2100 if (Page* page = m_frame->page()) { |
2102 if (page->mainFrame() == m_frame) | 2101 if (page->mainFrame() == m_frame) |
2103 m_frame->page()->inspectorController()->resume(); | 2102 m_frame->page()->inspectorController()->resume(); |
2104 } | 2103 } |
2105 | 2104 |
2106 setProvisionalDocumentLoader(m_policyDocumentLoader.get()); | 2105 setProvisionalDocumentLoader(m_policyDocumentLoader.get()); |
| 2106 m_loadType = type; |
2107 setState(FrameStateProvisional); | 2107 setState(FrameStateProvisional); |
2108 | 2108 |
2109 setPolicyDocumentLoader(0); | 2109 setPolicyDocumentLoader(0); |
2110 | 2110 |
2111 if (formState) | 2111 if (formState) |
2112 m_client->dispatchWillSubmitForm(formState); | 2112 m_client->dispatchWillSubmitForm(formState); |
2113 | 2113 |
2114 prepareForLoadStart(); | 2114 prepareForLoadStart(); |
2115 | 2115 |
2116 // The load might be cancelled inside of prepareForLoadStart(), nulling out
the m_provisionalDocumentLoader, | 2116 // The load might be cancelled inside of prepareForLoadStart(), nulling out
the m_provisionalDocumentLoader, |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2542 FloatRect newWindowRect = DOMWindow::adjustWindowRect(page, windowRect); | 2542 FloatRect newWindowRect = DOMWindow::adjustWindowRect(page, windowRect); |
2543 | 2543 |
2544 page->chrome().setWindowRect(newWindowRect); | 2544 page->chrome().setWindowRect(newWindowRect); |
2545 page->chrome().show(); | 2545 page->chrome().show(); |
2546 | 2546 |
2547 created = true; | 2547 created = true; |
2548 return frame; | 2548 return frame; |
2549 } | 2549 } |
2550 | 2550 |
2551 } // namespace WebCore | 2551 } // namespace WebCore |
OLD | NEW |