webengine/osswebengine/WebCore/loader/FrameLoader.cpp
changeset 11 c8a366e56285
parent 10 a359256acfc6
child 27 6297cdf66332
equal deleted inserted replaced
10:a359256acfc6 11:c8a366e56285
  1959 }
  1959 }
  1960 
  1960 
  1961 void FrameLoader::load(const KURL& URL, const String& referrer, FrameLoadType newLoadType,
  1961 void FrameLoader::load(const KURL& URL, const String& referrer, FrameLoadType newLoadType,
  1962     const String& frameName, Event* event, PassRefPtr<FormState> formState)
  1962     const String& frameName, Event* event, PassRefPtr<FormState> formState)
  1963 {
  1963 {
  1964     bool isFormSubmission = formState;
  1964     if ( URL != KURL("about:blank") )
  1965     
  1965     {
  1966     ResourceRequest request(URL);
  1966         bool isFormSubmission = formState;
  1967     if (!referrer.isEmpty())
       
  1968         request.setHTTPReferrer(referrer);
       
  1969     addExtraFieldsToRequest(request, true, event || isFormSubmission);
       
  1970     if (newLoadType == FrameLoadTypeReload)
       
  1971         request.setCachePolicy(ReloadIgnoringCacheData);
       
  1972 
       
  1973     ASSERT(newLoadType != FrameLoadTypeSame);
       
  1974 
       
  1975     NavigationAction action(URL, newLoadType, isFormSubmission, event);
       
  1976 
       
  1977     if (!frameName.isEmpty()) {
       
  1978         if (Frame* targetFrame = m_frame->tree()->find(frameName))
       
  1979             targetFrame->loader()->load(URL, referrer, newLoadType, String(), event, formState);
       
  1980         else
       
  1981             checkNewWindowPolicy(action, request, formState, frameName);
       
  1982         return;
       
  1983     }
       
  1984 
       
  1985     RefPtr<DocumentLoader> oldDocumentLoader = m_documentLoader;
       
  1986 
       
  1987     bool sameURL = shouldTreatURLAsSameAsCurrent(URL);
       
  1988     
       
  1989     // Make sure to do scroll to anchor processing even if the URL is
       
  1990     // exactly the same so pages with '#' links and DHTML side effects
       
  1991     // work properly.
       
  1992     if (!isFormSubmission
       
  1993         && newLoadType != FrameLoadTypeReload
       
  1994         && newLoadType != FrameLoadTypeSame
       
  1995         && !shouldReload(URL, url())
       
  1996         // We don't want to just scroll if a link from within a
       
  1997         // frameset is trying to reload the frameset into _top.
       
  1998         && !m_frame->isFrameSet()) {
       
  1999 
       
  2000         // Just do anchor navigation within the existing content.
       
  2001         
  1967         
  2002         // We don't do this if we are submitting a form, explicitly reloading,
  1968         ResourceRequest request(URL);
  2003         // currently displaying a frameset, or if the new URL does not have a fragment.
  1969         if (!referrer.isEmpty())
  2004         // These rules are based on what KHTML was doing in KHTMLPart::openURL.
  1970             request.setHTTPReferrer(referrer);
       
  1971         addExtraFieldsToRequest(request, true, event || isFormSubmission);
       
  1972         if (newLoadType == FrameLoadTypeReload)
       
  1973             request.setCachePolicy(ReloadIgnoringCacheData);
       
  1974     
       
  1975         ASSERT(newLoadType != FrameLoadTypeSame);
       
  1976     
       
  1977         NavigationAction action(URL, newLoadType, isFormSubmission, event);
       
  1978     
       
  1979         if (!frameName.isEmpty()) {
       
  1980             if (Frame* targetFrame = m_frame->tree()->find(frameName))
       
  1981                 targetFrame->loader()->load(URL, referrer, newLoadType, String(), event, formState);
       
  1982             else
       
  1983                 checkNewWindowPolicy(action, request, formState, frameName);
       
  1984             return;
       
  1985         }
       
  1986     
       
  1987         RefPtr<DocumentLoader> oldDocumentLoader = m_documentLoader;
       
  1988     
       
  1989         bool sameURL = shouldTreatURLAsSameAsCurrent(URL);
  2005         
  1990         
  2006         // FIXME: What about load types other than Standard and Reload?
  1991         // Make sure to do scroll to anchor processing even if the URL is
  2007         
  1992         // exactly the same so pages with '#' links and DHTML side effects
  2008         oldDocumentLoader->setTriggeringAction(action);
  1993         // work properly.
  2009         stopPolicyCheck();
  1994         if (!isFormSubmission
  2010         checkNavigationPolicy(request, oldDocumentLoader.get(), formState,
  1995             && newLoadType != FrameLoadTypeReload
  2011             callContinueFragmentScrollAfterNavigationPolicy, this);
  1996             && newLoadType != FrameLoadTypeSame
  2012     } else {
  1997             && !shouldReload(URL, url())
  2013         // must grab this now, since this load may stop the previous load and clear this flag
  1998             // We don't want to just scroll if a link from within a
  2014         bool isRedirect = m_quickRedirectComing;
  1999             // frameset is trying to reload the frameset into _top.
  2015         load(request, action, newLoadType, formState);
  2000             && !m_frame->isFrameSet()) {
  2016         if (isRedirect) {
  2001     
  2017             m_quickRedirectComing = false;
  2002             // Just do anchor navigation within the existing content.
  2018             if (m_provisionalDocumentLoader)
  2003             
  2019                 m_provisionalDocumentLoader->setIsClientRedirect(true);
  2004             // We don't do this if we are submitting a form, explicitly reloading,
  2020         } else if (sameURL)
  2005             // currently displaying a frameset, or if the new URL does not have a fragment.
  2021             // Example of this case are sites that reload the same URL with a different cookie
  2006             // These rules are based on what KHTML was doing in KHTMLPart::openURL.
  2022             // driving the generated content, or a master frame with links that drive a target
  2007             
  2023             // frame, where the user has clicked on the same link repeatedly.
  2008             // FIXME: What about load types other than Standard and Reload?
  2024             m_loadType = FrameLoadTypeSame;
  2009             
       
  2010             oldDocumentLoader->setTriggeringAction(action);
       
  2011             stopPolicyCheck();
       
  2012             checkNavigationPolicy(request, oldDocumentLoader.get(), formState,
       
  2013                 callContinueFragmentScrollAfterNavigationPolicy, this);
       
  2014         } else {
       
  2015             // must grab this now, since this load may stop the previous load and clear this flag
       
  2016             bool isRedirect = m_quickRedirectComing;
       
  2017             load(request, action, newLoadType, formState);
       
  2018             if (isRedirect) {
       
  2019                 m_quickRedirectComing = false;
       
  2020                 if (m_provisionalDocumentLoader)
       
  2021                     m_provisionalDocumentLoader->setIsClientRedirect(true);
       
  2022             } else if (sameURL)
       
  2023                 // Example of this case are sites that reload the same URL with a different cookie
       
  2024                 // driving the generated content, or a master frame with links that drive a target
       
  2025                 // frame, where the user has clicked on the same link repeatedly.
       
  2026                 m_loadType = FrameLoadTypeSame;
       
  2027         }
  2025     }
  2028     }
  2026 }
  2029 }
  2027 
  2030 
  2028 void FrameLoader::load(const ResourceRequest& request)
  2031 void FrameLoader::load(const ResourceRequest& request)
  2029 {
  2032 {