summaryrefslogtreecommitdiffstats
path: root/WebCore
diff options
context:
space:
mode:
authorKristian Monsen <kristianm@google.com>2010-07-06 11:37:41 +0100
committerKristian Monsen <kristianm@google.com>2010-07-15 12:55:05 +0100
commitff80790be406da04e7afbd8aea7bb0e26f1f08f0 (patch)
treebdcd94ef63cabf0e13e193a531b089c20bc2b177 /WebCore
parent31dbf1e39c75fa71a6175b95ce2172727630129b (diff)
downloadexternal_webkit-ff80790be406da04e7afbd8aea7bb0e26f1f08f0.zip
external_webkit-ff80790be406da04e7afbd8aea7bb0e26f1f08f0.tar.gz
external_webkit-ff80790be406da04e7afbd8aea7bb0e26f1f08f0.tar.bz2
Fix for bug 2816268: Refactor ANDROID_USER_GESTURE code
Used the UserGestureIndicator class instead of the local ANDROID_USER_GESTURE code. I have made a simple test case for the problem at: http://updates.monsen.it/source.html This cannot be made into a layout test since the Android Dumprendertree does not support focus on windows other than the main one. Lots of local changes removed, but not many actual changes. Most are in parameters sent to other functions. As far as I can see they user gestures are only checked for in ChromeClientAndroid.cpp and WebCoreFrameBridge.cpp, and I replaced ANDROID_USER_GESTURE with UserGestureIndicator::processingUserGesture(). The UserGestureIndicator class was added to webkit in this CL: http://trac.webkit.org/changeset/57045 ResourceRequest.h is a cherry-pick of this CL from webkit.org http://trac.webkit.org/changeset/62668 Change-Id: Ia254b2cee833459fcc2cacfb2751ef7a29a8f64a
Diffstat (limited to 'WebCore')
-rw-r--r--WebCore/config.h6
-rw-r--r--WebCore/loader/EmptyClients.h4
-rw-r--r--WebCore/loader/FrameLoader.cpp41
-rw-r--r--WebCore/loader/FrameLoader.h7
-rw-r--r--WebCore/loader/RedirectScheduler.cpp3
-rw-r--r--WebCore/page/Chrome.cpp7
-rw-r--r--WebCore/page/Chrome.h4
-rw-r--r--WebCore/page/ChromeClient.h4
-rw-r--r--WebCore/page/DOMWindow.cpp4
-rw-r--r--WebCore/platform/network/android/ResourceRequest.h11
10 files changed, 6 insertions, 85 deletions
diff --git a/WebCore/config.h b/WebCore/config.h
index c198305..8af4fe9 100644
--- a/WebCore/config.h
+++ b/WebCore/config.h
@@ -194,10 +194,8 @@
// apple-touch-icon support in <link> tags
#define ANDROID_APPLE_TOUCH_ICON
-// The user gesture flag is lost during a scheduled location change. We need to
-// maintain that flag until canHandleRequest to determine if a link was clicked
-// or if javascript tried to change the location.
-#define ANDROID_USER_GESTURE
+// Checking if an action is user initiated or not
+#define ANDROID_USER_GESTURE_CHECK
// Enable prefetching when specified via the rel element of <link> elements.
#define ENABLE_LINK_PREFETCH 1
diff --git a/WebCore/loader/EmptyClients.h b/WebCore/loader/EmptyClients.h
index 703ee0c..869de22 100644
--- a/WebCore/loader/EmptyClients.h
+++ b/WebCore/loader/EmptyClients.h
@@ -72,11 +72,7 @@ public:
virtual void webAppCanBeInstalled() { }
#endif
-#ifdef ANDROID_USER_GESTURE
- virtual void focus(bool userGesture) { }
-#else
virtual void focus() { }
-#endif
virtual void unfocus() { }
virtual bool canTakeFocus(FocusDirection) { return false; }
diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp
index 540e0f7..bdf7298 100644
--- a/WebCore/loader/FrameLoader.cpp
+++ b/WebCore/loader/FrameLoader.cpp
@@ -281,11 +281,7 @@ Frame* FrameLoader::createWindow(FrameLoader* frameLoaderForFrameLookup, const F
if (!request.resourceRequest().url().isEmpty())
frame->loader()->loadFrameRequest(request, false, false, 0, 0, SendReferrer);
if (Page* page = frame->page())
-#ifdef ANDROID_USER_GESTURE
- page->chrome()->focus(isProcessingUserGesture());
-#else
page->chrome()->focus();
-#endif
created = false;
return frame;
}
@@ -350,9 +346,6 @@ void FrameLoader::changeLocation(const KURL& url, const String& referrer, bool l
RefPtr<Frame> protect(m_frame);
ResourceRequest request(url, referrer, refresh ? ReloadIgnoringCacheData : UseProtocolCachePolicy);
-#ifdef ANDROID_USER_GESTURE
- request.setUserGesture(userGesture);
-#endif
urlSelected(request, "_self", 0, lockHistory, lockBackForwardList, userGesture, SendReferrer, ReplaceDocumentIfJavaScriptURL);
}
@@ -1019,11 +1012,7 @@ void FrameLoader::loadURLIntoChildFrame(const KURL& url, const String& referer,
childFrame->loader()->loadArchive(subframeArchive.release());
else
#endif
-#ifdef ANDROID_USER_GESTURE
- childFrame->loader()->loadURL(workingURL, referer, String(), false, childLoadType, 0, 0, false);
-#else
childFrame->loader()->loadURL(workingURL, referer, String(), false, childLoadType, 0, 0);
-#endif
}
#if ENABLE(ARCHIVE) // ANDROID extension: disabled to reduce code size
@@ -1372,17 +1361,10 @@ void FrameLoader::loadFrameRequest(const FrameLoadRequest& request, bool lockHis
else
loadType = FrameLoadTypeStandard;
-#ifdef ANDROID_USER_GESTURE
- if (request.resourceRequest().httpMethod() == "POST")
- loadPostRequest(request.resourceRequest(), referrer, request.frameName(), lockHistory, loadType, event, formState.get(), request.resourceRequest().getUserGesture());
- else
- loadURL(request.resourceRequest().url(), referrer, request.frameName(), lockHistory, loadType, event, formState.get(), request.resourceRequest().getUserGesture());
-#else
if (request.resourceRequest().httpMethod() == "POST")
loadPostRequest(request.resourceRequest(), referrer, request.frameName(), lockHistory, loadType, event, formState.get());
else
loadURL(request.resourceRequest().url(), referrer, request.frameName(), lockHistory, loadType, event, formState.get());
-#endif
// FIXME: It's possible this targetFrame will not be the same frame that was targeted by the actual
// load if frame names have changed.
@@ -1390,29 +1372,17 @@ void FrameLoader::loadFrameRequest(const FrameLoadRequest& request, bool lockHis
Frame* targetFrame = sourceFrame->loader()->findFrameForNavigation(request.frameName());
if (targetFrame && targetFrame != sourceFrame) {
if (Page* page = targetFrame->page())
-#ifdef ANDROID_USER_GESTURE
- page->chrome()->focus(request.resourceRequest().getUserGesture());
-#else
page->chrome()->focus();
-#endif
}
}
-#ifdef ANDROID_USER_GESTURE
-void FrameLoader::loadURL(const KURL& newURL, const String& referrer, const String& frameName, bool lockHistory, FrameLoadType newLoadType,
- PassRefPtr<Event> event, PassRefPtr<FormState> prpFormState, bool userGesture)
-#else
void FrameLoader::loadURL(const KURL& newURL, const String& referrer, const String& frameName, bool lockHistory, FrameLoadType newLoadType,
PassRefPtr<Event> event, PassRefPtr<FormState> prpFormState)
-#endif
{
RefPtr<FormState> formState = prpFormState;
bool isFormSubmission = formState;
ResourceRequest request(newURL);
-#ifdef ANDROID_USER_GESTURE
- request.setUserGesture(userGesture);
-#endif
if (!referrer.isEmpty()) {
request.setHTTPReferrer(referrer);
RefPtr<SecurityOrigin> referrerOrigin = SecurityOrigin::createFromString(referrer);
@@ -1427,11 +1397,7 @@ void FrameLoader::loadURL(const KURL& newURL, const String& referrer, const Stri
// The search for a target frame is done earlier in the case of form submission.
Frame* targetFrame = isFormSubmission ? 0 : findFrameForNavigation(frameName);
if (targetFrame && targetFrame != m_frame) {
-#ifdef ANDROID_USER_GESTURE
- targetFrame->loader()->loadURL(newURL, referrer, String(), lockHistory, newLoadType, event, formState.release(), userGesture);
-#else
targetFrame->loader()->loadURL(newURL, referrer, String(), lockHistory, newLoadType, event, formState.release());
-#endif
return;
}
@@ -2807,11 +2773,7 @@ void FrameLoader::committedLoad(DocumentLoader* loader, const char* data, int le
m_client->committedLoad(loader, data, length);
}
-#ifdef ANDROID_USER_GESTURE
-void FrameLoader::loadPostRequest(const ResourceRequest& inRequest, const String& referrer, const String& frameName, bool lockHistory, FrameLoadType loadType, PassRefPtr<Event> event, PassRefPtr<FormState> prpFormState, bool userGesture)
-#else
void FrameLoader::loadPostRequest(const ResourceRequest& inRequest, const String& referrer, const String& frameName, bool lockHistory, FrameLoadType loadType, PassRefPtr<Event> event, PassRefPtr<FormState> prpFormState)
-#endif
{
RefPtr<FormState> formState = prpFormState;
@@ -2831,9 +2793,6 @@ void FrameLoader::loadPostRequest(const ResourceRequest& inRequest, const String
String origin = inRequest.httpOrigin();
ResourceRequest workingResourceRequest(url);
-#ifdef ANDROID_USER_GESTURE
- workingResourceRequest.setUserGesture(userGesture);
-#endif
if (!referrer.isEmpty())
workingResourceRequest.setHTTPReferrer(referrer);
diff --git a/WebCore/loader/FrameLoader.h b/WebCore/loader/FrameLoader.h
index b361b51..e157850 100644
--- a/WebCore/loader/FrameLoader.h
+++ b/WebCore/loader/FrameLoader.h
@@ -404,17 +404,10 @@ private:
void loadWithNavigationAction(const ResourceRequest&, const NavigationAction&, // Calls loadWithDocumentLoader
bool lockHistory, FrameLoadType, PassRefPtr<FormState>);
-#ifdef ANDROID_USER_GESTURE
- void loadPostRequest(const ResourceRequest&, const String& referrer, // Called by loadFrameRequest, calls loadWithNavigationAction
- const String& frameName, bool lockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>, bool);
- void loadURL(const KURL&, const String& referrer, const String& frameName, // Called by loadFrameRequest, calls loadWithNavigationAction or dispatches to navigation policy delegate
- bool lockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>, bool);
-#else
void loadPostRequest(const ResourceRequest&, const String& referrer, // Called by loadFrameRequest, calls loadWithNavigationAction
const String& frameName, bool lockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>);
void loadURL(const KURL&, const String& referrer, const String& frameName, // Called by loadFrameRequest, calls loadWithNavigationAction or dispatches to navigation policy delegate
bool lockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>);
-#endif
bool shouldReload(const KURL& currentURL, const KURL& destinationURL);
diff --git a/WebCore/loader/RedirectScheduler.cpp b/WebCore/loader/RedirectScheduler.cpp
index 4fda8fe..3cfe61a 100644
--- a/WebCore/loader/RedirectScheduler.cpp
+++ b/WebCore/loader/RedirectScheduler.cpp
@@ -191,9 +191,6 @@ public:
if (!m_submission->state()->sourceFrame()->loader()->shouldAllowNavigation(frame))
return;
FrameLoadRequest frameRequest;
-#ifdef ANDROID_USER_GESTURE
- frameRequest.resourceRequest().setUserGesture(m_submission->state()->sourceFrame()->loader()->isProcessingUserGesture());
-#endif
m_submission->populateFrameLoadRequest(frameRequest);
frame->loader()->loadFrameRequest(frameRequest, lockHistory(), lockBackForwardList(), m_submission->event(), m_submission->state(), SendReferrer);
}
diff --git a/WebCore/page/Chrome.cpp b/WebCore/page/Chrome.cpp
index 799aaee..0124211 100644
--- a/WebCore/page/Chrome.cpp
+++ b/WebCore/page/Chrome.cpp
@@ -138,17 +138,10 @@ float Chrome::scaleFactor()
return m_client->scaleFactor();
}
-#ifdef ANDROID_USER_GESTURE
-void Chrome::focus(bool userGesture) const
-{
- m_client->focus(userGesture);
-}
-#else
void Chrome::focus() const
{
m_client->focus();
}
-#endif
void Chrome::unfocus() const
{
diff --git a/WebCore/page/Chrome.h b/WebCore/page/Chrome.h
index 3882f5e..88035a5 100644
--- a/WebCore/page/Chrome.h
+++ b/WebCore/page/Chrome.h
@@ -81,11 +81,7 @@ namespace WebCore {
float scaleFactor();
-#ifdef ANDROID_USER_GESTURE
- void focus(bool userGesture) const;
-#else
void focus() const;
-#endif
void unfocus() const;
bool canTakeFocus(FocusDirection) const;
diff --git a/WebCore/page/ChromeClient.h b/WebCore/page/ChromeClient.h
index 660ec68..64b9f26 100644
--- a/WebCore/page/ChromeClient.h
+++ b/WebCore/page/ChromeClient.h
@@ -79,11 +79,7 @@ namespace WebCore {
virtual float scaleFactor() = 0;
-#ifdef ANDROID_USER_GESTURE
- virtual void focus(bool userGesture) = 0;
-#else
virtual void focus() = 0;
-#endif
virtual void unfocus() = 0;
virtual bool canTakeFocus(FocusDirection) = 0;
diff --git a/WebCore/page/DOMWindow.cpp b/WebCore/page/DOMWindow.cpp
index f050a80..6ecde3c 100644
--- a/WebCore/page/DOMWindow.cpp
+++ b/WebCore/page/DOMWindow.cpp
@@ -779,11 +779,7 @@ void DOMWindow::focus()
// If we're a top level window, bring the window to the front.
if (m_frame == page->mainFrame())
-#ifdef ANDROID_USER_GESTURE
- page->chrome()->focus(m_frame->loader()->isProcessingUserGesture());
-#else
page->chrome()->focus();
-#endif
if (!m_frame)
return;
diff --git a/WebCore/platform/network/android/ResourceRequest.h b/WebCore/platform/network/android/ResourceRequest.h
index 3102ff1..1edd4bf 100644
--- a/WebCore/platform/network/android/ResourceRequest.h
+++ b/WebCore/platform/network/android/ResourceRequest.h
@@ -36,26 +36,23 @@ namespace WebCore {
class ResourceRequest : public ResourceRequestBase {
public:
ResourceRequest(const String& url)
- : ResourceRequestBase(KURL(ParsedURLString, url), UseProtocolCachePolicy), m_userGesture(true) { }
+ : ResourceRequestBase(KURL(ParsedURLString, url), UseProtocolCachePolicy) { }
- ResourceRequest(const KURL& url) : ResourceRequestBase(url, UseProtocolCachePolicy) , m_userGesture(true) { }
+ ResourceRequest(const KURL& url) : ResourceRequestBase(url, UseProtocolCachePolicy) { }
ResourceRequest(const KURL& url, const String& referrer, ResourceRequestCachePolicy policy = UseProtocolCachePolicy)
- : ResourceRequestBase(url, policy) , m_userGesture(true)
+ : ResourceRequestBase(url, policy)
{
setHTTPReferrer(referrer);
}
- ResourceRequest() : ResourceRequestBase(KURL(), UseProtocolCachePolicy), m_userGesture(true) { }
+ ResourceRequest() : ResourceRequestBase(KURL(), UseProtocolCachePolicy) { }
void doUpdatePlatformRequest() { }
void doUpdateResourceRequest() { }
- void setUserGesture(bool userGesture) { m_userGesture = userGesture; }
- bool getUserGesture() const { return m_userGesture; }
private:
friend class ResourceRequestBase;
- bool m_userGesture;
};
} // namespace WebCore