summaryrefslogtreecommitdiffstats
path: root/WebCore/loader
diff options
context:
space:
mode:
authorPatrick Scott <phanna@android.com>2009-11-18 13:55:30 -0500
committerPatrick Scott <phanna@android.com>2009-11-19 09:19:18 -0500
commit27e40b2407e7e39b8fde83728baee90aae279760 (patch)
treef06d6bbc372c2f3541721893f0c6e1e2bef7a085 /WebCore/loader
parent19e61e8bbfd288bd9bf211069dd66e51ffadce15 (diff)
downloadexternal_webkit-27e40b2407e7e39b8fde83728baee90aae279760.zip
external_webkit-27e40b2407e7e39b8fde83728baee90aae279760.tar.gz
external_webkit-27e40b2407e7e39b8fde83728baee90aae279760.tar.bz2
Change window focus only if the user initiated the event.
This does not work in the javascript case because the user gesture is stored in the caller's script environment and that knowledge is not obtainable in the receiving frame. However, this change allows targeted links to change the focus to the correct window but prevents sites like slate.com from changing back to the opening window. This change will be followed by a simple revert of the previous change in the Browser app. Bug: 2161671
Diffstat (limited to 'WebCore/loader')
-rw-r--r--WebCore/loader/EmptyClients.h4
-rw-r--r--WebCore/loader/FrameLoader.cpp8
2 files changed, 12 insertions, 0 deletions
diff --git a/WebCore/loader/EmptyClients.h b/WebCore/loader/EmptyClients.h
index 44fad72..b4952b1 100644
--- a/WebCore/loader/EmptyClients.h
+++ b/WebCore/loader/EmptyClients.h
@@ -70,7 +70,11 @@ public:
virtual float scaleFactor() { return 1.f; }
+#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 80fcff8..f9dc2bf 100644
--- a/WebCore/loader/FrameLoader.cpp
+++ b/WebCore/loader/FrameLoader.cpp
@@ -262,7 +262,11 @@ 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;
}
@@ -1882,7 +1886,11 @@ 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
}
}