Commit 5a1e60e0 authored by darin's avatar darin

Oops, rolled that last change out. I'll redo it again later after making

        som additional refinments.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@20921 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7df91513
2007-04-17 Darin Adler <darin@apple.com>
Oops, rolled that last change out. I'll redo it again later after making
som additional refinments.
2007-04-17 Darin Adler <darin@apple.com>
Reviewed by Brady.
......@@ -349,8 +349,7 @@ void JSHTMLDocument::putValueProperty(ExecState* exec, int token, JSValue *value
// We want a new history item if this JS was called via a user gesture
bool userGesture = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter())->wasRunByUserGesture();
// FIXME: This always passes false for userGesture.
frame->loader()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !userGesture, false);
frame->loader()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !userGesture);
}
break;
case BgColor:
......
......@@ -257,7 +257,7 @@ Frame* FrameLoader::createWindow(const FrameLoadRequest& request, const WindowFe
if (!request.frameName().isEmpty() && request.frameName() != "_blank")
if (Frame* frame = m_frame->tree()->find(request.frameName())) {
if (!request.resourceRequest().url().isEmpty())
frame->loader()->load(request, 0, 0, HashMap<String, String>());
frame->loader()->load(request, true, 0, 0, HashMap<String, String>());
frame->page()->chrome()->focus();
return frame;
}
......@@ -331,12 +331,9 @@ void FrameLoader::changeLocation(const String& URL, const String& referrer, bool
urlSelected(request, "_self", 0, lockHistory, userGesture);
}
void FrameLoader::urlSelected(const ResourceRequest& request, const String& explicitTarget, Event* triggeringEvent, bool lockHistory, bool userGesture)
void FrameLoader::urlSelected(const ResourceRequest& request, const String& _target, Event* triggeringEvent, bool lockHistory, bool userGesture)
{
// FIXME: This function ignores the lockHistory parameter and does not pass it along
// in the FrameLoadRequest it creates.
String target = explicitTarget;
String target = _target;
if (target.isEmpty() && m_frame->document())
target = m_frame->document()->baseTarget();
......@@ -350,12 +347,11 @@ void FrameLoader::urlSelected(const ResourceRequest& request, const String& expl
return;
FrameLoadRequest frameRequest(request, target);
frameRequest.setIsUserGesture(userGesture);
if (frameRequest.resourceRequest().httpReferrer().isEmpty())
frameRequest.resourceRequest().setHTTPReferrer(m_outgoingReferrer);
load(frameRequest, triggeringEvent, 0, HashMap<String, String>());
urlSelected(frameRequest, triggeringEvent, userGesture);
}
bool FrameLoader::requestFrame(HTMLFrameOwnerElement* ownerElement, const String& urlString, const AtomicString& frameName)
......@@ -1717,42 +1713,46 @@ void FrameLoader::finalSetupForReplace(DocumentLoader* loader)
void FrameLoader::load(const KURL& URL, Event* event)
{
load(ResourceRequest(URL), event, 0, HashMap<String, String>());
load(ResourceRequest(URL), true, event, 0, HashMap<String, String>());
}
void FrameLoader::load(const FrameLoadRequest& request, Event* event,
void FrameLoader::load(const FrameLoadRequest& request, bool userGesture, Event* event,
HTMLFormElement* submitForm, const HashMap<String, String>& formValues)
{
String referrer = request.resourceRequest().httpReferrer();
if (referrer.isEmpty())
String referrer;
String argsReferrer = request.resourceRequest().httpReferrer();
if (!argsReferrer.isEmpty())
referrer = argsReferrer;
else
referrer = m_outgoingReferrer;
bool hideReferrer;
if (!canLoad(request.resourceRequest().url(), referrer, hideReferrer)) {
FrameLoader::reportLocalLoadFailed(frame()->page(), request.resourceRequest().url().url());
return;
}
if (hideReferrer)
referrer = String();
Frame* targetFrame = m_frame->tree()->find(request.frameName());
if (!canTarget(targetFrame))
return;
if (request.resourceRequest().httpMethod() != "POST") {
FrameLoadType loadType;
if (request.resourceRequest().cachePolicy() == ReloadIgnoringCacheData)
loadType = FrameLoadTypeReload;
else if (!request.isUserGesture())
else if (!userGesture)
loadType = FrameLoadTypeInternal;
else
loadType = FrameLoadTypeStandard;
loadType = FrameLoadTypeStandard;
load(request.resourceRequest().url(), referrer, loadType,
request.frameName(), event, submitForm, formValues);
} else
post(request.resourceRequest().url(), referrer, request.frameName(),
request.resourceRequest().httpBody(), request.resourceRequest().httpContentType(),
event, submitForm, formValues);
request.resourceRequest().httpBody(), request.resourceRequest().httpContentType(), event, submitForm, formValues);
if (targetFrame && targetFrame != m_frame)
targetFrame->page()->chrome()->focus();
......@@ -2823,11 +2823,21 @@ void FrameLoader::submitForm(const FrameLoadRequest& request, Event* event)
m_submittedFormURL = request.resourceRequest().url();
}
load(request, event, m_formAboutToBeSubmitted.get(), m_formValuesAboutToBeSubmitted);
// FIXME: Why do we always pass true for userGesture?
load(request, true, event, m_formAboutToBeSubmitted.get(), m_formValuesAboutToBeSubmitted);
clearRecordedFormValues();
}
void FrameLoader::urlSelected(const FrameLoadRequest& request, Event* event, bool userGesture)
{
FrameLoadRequest copy = request;
if (copy.resourceRequest().httpReferrer().isEmpty())
copy.resourceRequest().setHTTPReferrer(m_outgoingReferrer);
load(copy, userGesture, event, 0, HashMap<String, String>());
}
String FrameLoader::userAgent(const KURL& url) const
{
return m_client->userAgent(url);
......
......@@ -132,7 +132,7 @@ namespace WebCore {
void setupForReplaceByMIMEType(const String& newMIMEType);
void finalSetupForReplace(DocumentLoader*);
void load(const KURL&, Event*);
void load(const FrameLoadRequest&,
void load(const FrameLoadRequest&, bool userGesture,
Event*, HTMLFormElement*, const HashMap<String, String>& formValues);
void load(const KURL&, const String& referrer, FrameLoadType, const String& target,
Event*, HTMLFormElement*, const HashMap<String, String>& formValues);
......@@ -262,8 +262,9 @@ namespace WebCore {
void setDefersLoading(bool);
void changeLocation(const String& URL, const String& referrer, bool lockHistory, bool userGesture);
void changeLocation(const String& URL, const String& referrer, bool lockHistory = true, bool userGesture = false);
void urlSelected(const ResourceRequest&, const String& target, Event*, bool lockHistory, bool userGesture);
void urlSelected(const FrameLoadRequest&, Event*, bool userGesture);
bool requestFrame(HTMLFrameOwnerElement*, const String& URL, const AtomicString& frameName);
Frame* loadSubframe(HTMLFrameOwnerElement*, const KURL& URL, const String& name, const String& referrer);
......@@ -287,8 +288,8 @@ namespace WebCore {
void scheduleRedirection(double delay, const String& URL);
void scheduleLocationChange(const String& URL, const String& referrer, bool lockHistory, bool userGesture);
void scheduleRefresh(bool userGesture);
void scheduleLocationChange(const String& URL, const String& referrer, bool lockHistory = true, bool userGesture = false);
void scheduleRefresh(bool userGesture = false);
bool isScheduledLocationChangePending() const;
void scheduleHistoryNavigation(int steps);
......
......@@ -195,13 +195,14 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuItem* item)
// FIXME: Some day we may be able to do this from within WebCore.
m_client->lookUpInDictionary(frame);
break;
case ContextMenuItemTagOpenLink:
case ContextMenuItemTagOpenLink: {
if (Frame* targetFrame = result.targetFrame())
targetFrame->loader()->load(ResourceRequest(result.absoluteLinkURL(),
frame->loader()->outgoingReferrer()), 0, 0, HashMap<String, String>());
targetFrame->loader()->load(FrameLoadRequest(ResourceRequest(result.absoluteLinkURL(),
frame->loader()->outgoingReferrer())), true, 0, 0, HashMap<String, String>());
else
openNewWindow(result.absoluteLinkURL(), frame);
break;
}
case ContextMenuItemTagBold:
frame->editor()->execCommand("ToggleBold");
break;
......
......@@ -34,23 +34,20 @@ namespace WebCore {
struct FrameLoadRequest {
public:
FrameLoadRequest()
: m_shouldLockHistory(false)
, m_isUserGesture(true)
: m_lockHistory(false)
{
}
FrameLoadRequest(const ResourceRequest& resourceRequest)
: m_resourceRequest(resourceRequest)
, m_shouldLockHistory(false)
, m_isUserGesture(true)
, m_lockHistory(false)
{
}
FrameLoadRequest(const ResourceRequest& resourceRequest, const String& frameName)
: m_resourceRequest(resourceRequest)
, m_frameName(frameName)
, m_shouldLockHistory(false)
, m_isUserGesture(true)
, m_lockHistory(false)
{
}
......@@ -62,17 +59,13 @@ namespace WebCore {
const String& frameName() const { return m_frameName; }
void setFrameName(const String& frameName) { m_frameName = frameName; }
bool shouldLockHistory() const { return m_shouldLockHistory; }
void setShouldLockHistory(bool lock) { m_shouldLockHistory = lock; }
bool isUserGesture() const { return m_isUserGesture; }
void setIsUserGesture(bool userGesture) { m_isUserGesture = userGesture; }
bool lockHistory() const { return m_lockHistory; }
void setLockHistory(bool lock) { m_lockHistory = lock; }
private:
ResourceRequest m_resourceRequest;
String m_frameName;
bool m_shouldLockHistory;
bool m_isUserGesture;
bool m_lockHistory;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment