Commit a3a3cbd4 authored by darin's avatar darin

Reviewed by Brady.

        - a few baby steps to try to make lockHistory and userGesture less confusing

        * page/FrameLoadRequest.h:
        (WebCore::FrameLoadRequest::FrameLoadRequest): Add initialization of m_isUserGesture
        to true.
        (WebCore::FrameLoadRequest::shouldLockHistory): Renamed from lockHistory to avoid having
        a getter that sounds like a verb phrase.
        (WebCore::FrameLoadRequest::setShouldLockHistory): Ditto.
        (WebCore::FrameLoadRequest::isUserGesture): Added.
        (WebCore::FrameLoadRequest::setIsUserGesture): Ditto.

        * loader/FrameLoader.h: Remove userGesture parameter from load that takes
        FrameLoadRequest. Remove default values for lockHistory and userGesture parameters,
        since that just makes it more likely we'll forget to pass them in. Remove one of
        the overloads of urlSelected, since it's only called one place.

        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::createWindow): Remove userGesture parameter, relying on
        the true default in FrameLoadRequest.
        (WebCore::FrameLoader::urlSelected): Call setShouldLockHistory and setIsUserGesture
        on the FrameLoadRequest, and call load directly; also eliminate the other urlSelected
        overload since this was the only place it was called.
        (WebCore::FrameLoader::load): Remove userGesture parameter, relying on the true
        default in FrameLoadRequest. In the other overload, clean up logic to eliminate the
        argsReferrer variable and get rid of the userGesture parameter, using the value from
        FrameLoadRequest.
        (WebCore::FrameLoader::submitForm): Remove userGesture parameter, relying on the value
        in the FrameLoadRequest. This actually changes behavior.

        * bindings/js/kjs_html.cpp: (KJS::JSHTMLDocument::putValueProperty): Pass
        false for userGesture explicitly instead of relying on default argument.

        * page/ContextMenuController.cpp: (WebCore::ContextMenuController::contextMenuItemSelected):
        Remove userGesture parameter, relying on the true default in FrameLoadRequest.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@20919 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f96fcbdf
2007-04-17 Darin Adler <darin@apple.com>
Reviewed by Brady.
- a few baby steps to try to make lockHistory and userGesture less confusing
* page/FrameLoadRequest.h:
(WebCore::FrameLoadRequest::FrameLoadRequest): Add initialization of m_isUserGesture
to true.
(WebCore::FrameLoadRequest::shouldLockHistory): Renamed from lockHistory to avoid having
a getter that sounds like a verb phrase.
(WebCore::FrameLoadRequest::setShouldLockHistory): Ditto.
(WebCore::FrameLoadRequest::isUserGesture): Added.
(WebCore::FrameLoadRequest::setIsUserGesture): Ditto.
* loader/FrameLoader.h: Remove userGesture parameter from load that takes
FrameLoadRequest. Remove default values for lockHistory and userGesture parameters,
since that just makes it more likely we'll forget to pass them in. Remove one of
the overloads of urlSelected, since it's only called one place.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::createWindow): Remove userGesture parameter, relying on
the true default in FrameLoadRequest.
(WebCore::FrameLoader::urlSelected): Call setShouldLockHistory and setIsUserGesture
on the FrameLoadRequest, and call load directly; also eliminate the other urlSelected
overload since this was the only place it was called.
(WebCore::FrameLoader::load): Remove userGesture parameter, relying on the true
default in FrameLoadRequest. In the other overload, clean up logic to eliminate the
argsReferrer variable and get rid of the userGesture parameter, using the value from
FrameLoadRequest.
(WebCore::FrameLoader::submitForm): Remove userGesture parameter, relying on the value
in the FrameLoadRequest. This actually changes behavior.
* bindings/js/kjs_html.cpp: (KJS::JSHTMLDocument::putValueProperty): Pass
false for userGesture explicitly instead of relying on default argument.
* page/ContextMenuController.cpp: (WebCore::ContextMenuController::contextMenuItemSelected):
Remove userGesture parameter, relying on the true default in FrameLoadRequest.
2007-04-16 David Kilzer <ddkilzer@webkit.org>
Reviewed by NOBODY (fixed misspelling).
......@@ -349,7 +349,8 @@ 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();
frame->loader()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !userGesture);
// FIXME: This always passes false for userGesture.
frame->loader()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !userGesture, false);
}
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, true, 0, 0, HashMap<String, String>());
frame->loader()->load(request, 0, 0, HashMap<String, String>());
frame->page()->chrome()->focus();
return frame;
}
......@@ -331,9 +331,12 @@ void FrameLoader::changeLocation(const String& URL, const String& referrer, bool
urlSelected(request, "_self", 0, lockHistory, userGesture);
}
void FrameLoader::urlSelected(const ResourceRequest& request, const String& _target, Event* triggeringEvent, bool lockHistory, bool userGesture)
void FrameLoader::urlSelected(const ResourceRequest& request, const String& explicitTarget, Event* triggeringEvent, bool lockHistory, bool userGesture)
{
String target = _target;
// FIXME: This function ignores the lockHistory parameter and does not pass it along
// in the FrameLoadRequest it creates.
String target = explicitTarget;
if (target.isEmpty() && m_frame->document())
target = m_frame->document()->baseTarget();
......@@ -347,11 +350,12 @@ void FrameLoader::urlSelected(const ResourceRequest& request, const String& _tar
return;
FrameLoadRequest frameRequest(request, target);
frameRequest.setIsUserGesture(userGesture);
if (frameRequest.resourceRequest().httpReferrer().isEmpty())
frameRequest.resourceRequest().setHTTPReferrer(m_outgoingReferrer);
urlSelected(frameRequest, triggeringEvent, userGesture);
load(frameRequest, triggeringEvent, 0, HashMap<String, String>());
}
bool FrameLoader::requestFrame(HTMLFrameOwnerElement* ownerElement, const String& urlString, const AtomicString& frameName)
......@@ -1713,46 +1717,42 @@ void FrameLoader::finalSetupForReplace(DocumentLoader* loader)
void FrameLoader::load(const KURL& URL, Event* event)
{
load(ResourceRequest(URL), true, event, 0, HashMap<String, String>());
load(ResourceRequest(URL), event, 0, HashMap<String, String>());
}
void FrameLoader::load(const FrameLoadRequest& request, bool userGesture, Event* event,
void FrameLoader::load(const FrameLoadRequest& request, Event* event,
HTMLFormElement* submitForm, const HashMap<String, String>& formValues)
{
String referrer;
String argsReferrer = request.resourceRequest().httpReferrer();
if (!argsReferrer.isEmpty())
referrer = argsReferrer;
else
String referrer = request.resourceRequest().httpReferrer();
if (referrer.isEmpty())
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 (!userGesture)
else if (!request.isUserGesture())
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,21 +2823,11 @@ void FrameLoader::submitForm(const FrameLoadRequest& request, Event* event)
m_submittedFormURL = request.resourceRequest().url();
}
// FIXME: Why do we always pass true for userGesture?
load(request, true, event, m_formAboutToBeSubmitted.get(), m_formValuesAboutToBeSubmitted);
load(request, 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&, bool userGesture,
void load(const FrameLoadRequest&,
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,9 +262,8 @@ namespace WebCore {
void setDefersLoading(bool);
void changeLocation(const String& URL, const String& referrer, bool lockHistory = true, bool userGesture = false);
void changeLocation(const String& URL, const String& referrer, bool lockHistory, bool userGesture);
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);
......@@ -288,8 +287,8 @@ namespace WebCore {
void scheduleRedirection(double delay, const String& URL);
void scheduleLocationChange(const String& URL, const String& referrer, bool lockHistory = true, bool userGesture = false);
void scheduleRefresh(bool userGesture = false);
void scheduleLocationChange(const String& URL, const String& referrer, bool lockHistory, bool userGesture);
void scheduleRefresh(bool userGesture);
bool isScheduledLocationChangePending() const;
void scheduleHistoryNavigation(int steps);
......
......@@ -195,14 +195,13 @@ 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(FrameLoadRequest(ResourceRequest(result.absoluteLinkURL(),
frame->loader()->outgoingReferrer())), true, 0, 0, HashMap<String, String>());
targetFrame->loader()->load(ResourceRequest(result.absoluteLinkURL(),
frame->loader()->outgoingReferrer()), 0, 0, HashMap<String, String>());
else
openNewWindow(result.absoluteLinkURL(), frame);
break;
}
case ContextMenuItemTagBold:
frame->editor()->execCommand("ToggleBold");
break;
......
......@@ -34,20 +34,23 @@ namespace WebCore {
struct FrameLoadRequest {
public:
FrameLoadRequest()
: m_lockHistory(false)
: m_shouldLockHistory(false)
, m_isUserGesture(true)
{
}
FrameLoadRequest(const ResourceRequest& resourceRequest)
: m_resourceRequest(resourceRequest)
, m_lockHistory(false)
, m_shouldLockHistory(false)
, m_isUserGesture(true)
{
}
FrameLoadRequest(const ResourceRequest& resourceRequest, const String& frameName)
: m_resourceRequest(resourceRequest)
, m_frameName(frameName)
, m_lockHistory(false)
, m_shouldLockHistory(false)
, m_isUserGesture(true)
{
}
......@@ -59,13 +62,17 @@ namespace WebCore {
const String& frameName() const { return m_frameName; }
void setFrameName(const String& frameName) { m_frameName = frameName; }
bool lockHistory() const { return m_lockHistory; }
void setLockHistory(bool lock) { m_lockHistory = lock; }
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; }
private:
ResourceRequest m_resourceRequest;
String m_frameName;
bool m_lockHistory;
bool m_shouldLockHistory;
bool m_isUserGesture;
};
}
......
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