summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.cc24
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.h37
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_gtk.cc8
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_mac.mm39
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_win.cc8
5 files changed, 48 insertions, 68 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.cc b/webkit/glue/plugins/webplugin_delegate_impl.cc
index beaddfc..b73b5ae 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl.cc
@@ -156,30 +156,6 @@ void WebPluginDelegateImpl::UpdateGeometry(
}
}
-void WebPluginDelegateImpl::SetFocus(bool focused) {
- DCHECK(windowless_);
- // This is called when internal WebKit focus (the focused element on the page)
- // changes, but plugins need to know about OS-level focus, so we have an extra
- // layer of focus tracking.
- has_webkit_focus_ = focused;
- if (containing_view_has_focus_)
- SetPluginHasFocus(focused);
-}
-
-void WebPluginDelegateImpl::SetPluginHasFocus(bool focused) {
- if (focused == plugin_has_focus_)
- return;
- if (PlatformSetPluginHasFocus(focused))
- plugin_has_focus_ = focused;
-}
-
-void WebPluginDelegateImpl::SetContentAreaHasFocus(bool has_focus) {
- containing_view_has_focus_ = has_focus;
- if (!windowless_)
- return;
- SetPluginHasFocus(containing_view_has_focus_ && has_webkit_focus_);
-}
-
NPObject* WebPluginDelegateImpl::GetPluginScriptableObject() {
return instance_->GetPluginScriptableObject();
}
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h
index 961b311..b20cd67 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.h
+++ b/webkit/glue/plugins/webplugin_delegate_impl.h
@@ -137,9 +137,6 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
// Returns a combination of PluginQuirks.
int GetQuirks() const { return quirks_; }
- // Informs the plugin that the view it is in has gained or lost focus.
- void SetContentAreaHasFocus(bool has_focus);
-
#if defined(OS_MACOSX)
// Informs the plugin that the geometry has changed, as with UpdateGeometry,
// but also includes the new buffer context for that new geometry.
@@ -153,14 +150,16 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
static WebPluginDelegateImpl* GetActiveDelegate();
// Informs the plugin that the window it is in has gained or lost focus.
void SetWindowHasFocus(bool has_focus);
+ // Informs the plugin that the view it is in has gained or lost first
+ // responder status.
+ void SetContentAreaHasFocus(bool has_focus);
// Returns whether or not the window the plugin is in has focus.
bool GetWindowHasFocus() const { return containing_window_has_focus_; }
// Informs the plugin that its tab or window has been hidden or shown.
void SetContainerVisibility(bool is_visible);
// Informs the plugin that its containing window's frame has changed.
// Frames are in screen coordinates.
- void WindowFrameChanged(const gfx::Rect& window_frame,
- const gfx::Rect& view_frame);
+ void WindowFrameChanged(gfx::Rect window_frame, gfx::Rect view_frame);
// Informs the delegate that the plugin set a Carbon ThemeCursor.
void SetThemeCursor(ThemeCursor cursor);
// Informs the delegate that the plugin set a Carbon Cursor.
@@ -255,14 +254,6 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
// See NPAPI NPP_SetWindow for more information.
void WindowlessSetWindow();
- // Informs the plugin that it has gained or lost keyboard focus (on the Mac,
- // this just means window first responder status).
- void SetPluginHasFocus(bool focused);
-
- // Handles the platform specific details of setting plugin focus. Returns
- // false if the platform cancelled the focus tranfer.
- bool PlatformSetPluginHasFocus(bool focused);
-
//-----------------------------------------
// used for windowed and windowless plugins
@@ -386,6 +377,10 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
// Updates everything that depends on the plugin's absolute screen location.
void PluginScreenLocationChanged();
+ // Informs the plugin that it has gained or lost keyboard focus (i.e., window
+ // first responder status).
+ void SetPluginHasFocus(bool has_focus);
+
// Returns the apparent zoom ratio for the given event, as inferred from our
// current knowledge about about where on screen the plugin is.
// This is a temporary workaround for <http://crbug.com/9996>; once that is
@@ -440,6 +435,14 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
// relative to an upper-left (0,0).
gfx::Point content_area_origin_;
+ // True if the plugin thinks it has keyboard focus
+ bool plugin_has_focus_;
+ // True if the plugin element has focus within the page, regardless of whether
+ // its containing view is currently the first responder for the window.
+ bool has_webkit_focus_;
+ // True if the containing view is the window's first responder.
+ bool containing_view_has_focus_;
+
bool containing_window_has_focus_;
bool initial_window_focus_;
bool container_is_visible_;
@@ -492,14 +495,6 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
// call received by the plugin.
bool first_set_window_call_;
- // True if the plugin thinks it has keyboard focus
- bool plugin_has_focus_;
- // True if the plugin element has focus within the web content, regardless of
- // whether its containing view currently has focus.
- bool has_webkit_focus_;
- // True if the containing view currently has focus.
- bool containing_view_has_focus_;
-
DISALLOW_COPY_AND_ASSIGN(WebPluginDelegateImpl);
};
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
index 3c9a985..d4a98a8 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
@@ -52,10 +52,7 @@ WebPluginDelegateImpl::WebPluginDelegateImpl(
parent_(containing_view),
quirks_(0),
handle_event_depth_(0),
- first_set_window_call_(true),
- plugin_has_focus_(false),
- has_webkit_focus_(false),
- containing_view_has_focus_(false) {
+ first_set_window_call_(true) {
memset(&window_, 0, sizeof(window_));
if (instance_->mime_type() == "application/x-shockwave-flash") {
// Flash is tied to Firefox's whacky behavior with windowless plugins. See
@@ -541,7 +538,7 @@ void WebPluginDelegateImpl::WindowlessSetWindow() {
}
}
-bool WebPluginDelegateImpl::PlatformSetPluginHasFocus(bool focused) {
+void WebPluginDelegateImpl::SetFocus(bool focused) {
DCHECK(instance()->windowless());
NPEvent np_event = {0};
@@ -552,7 +549,6 @@ bool WebPluginDelegateImpl::PlatformSetPluginHasFocus(bool focused) {
event.mode = -1;
event.detail = NotifyDetailNone;
instance()->NPP_HandleEvent(&np_event);
- return true;
}
// Converts a WebInputEvent::Modifiers bitfield into a
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
index bcb13ff..dd3a83b 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
+++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
@@ -258,16 +258,16 @@ WebPluginDelegateImpl::WebPluginDelegateImpl(
layer_(nil),
surface_(NULL),
renderer_(nil),
+ plugin_has_focus_(false),
+ has_webkit_focus_(false),
+ containing_view_has_focus_(false),
containing_window_has_focus_(false),
initial_window_focus_(false),
container_is_visible_(false),
have_called_set_window_(false),
external_drag_tracker_(new ExternalDragTracker()),
handle_event_depth_(0),
- first_set_window_call_(true),
- plugin_has_focus_(false),
- has_webkit_focus_(false),
- containing_view_has_focus_(false) {
+ first_set_window_call_(true) {
memset(&window_, 0, sizeof(window_));
#ifndef NP_NO_CARBON
memset(&np_cg_context_, 0, sizeof(np_cg_context_));
@@ -466,6 +466,15 @@ void WebPluginDelegateImpl::Print(CGContextRef context) {
NOTIMPLEMENTED();
}
+void WebPluginDelegateImpl::SetFocus(bool focused) {
+ // This is called when internal WebKit focus (the focused element on the page)
+ // changes, but plugins need to know about actual first responder status, so
+ // we have an extra layer of focus tracking.
+ has_webkit_focus_ = focused;
+ if (containing_view_has_focus_)
+ SetPluginHasFocus(focused);
+}
+
bool WebPluginDelegateImpl::PlatformHandleInputEvent(
const WebInputEvent& event, WebCursorInfo* cursor_info) {
DCHECK(cursor_info != NULL);
@@ -814,9 +823,13 @@ void WebPluginDelegateImpl::SetWindowHasFocus(bool has_focus) {
}
}
-bool WebPluginDelegateImpl::PlatformSetPluginHasFocus(bool focused) {
+void WebPluginDelegateImpl::SetPluginHasFocus(bool has_focus) {
if (!have_called_set_window_)
- return false;
+ return;
+
+ if (has_focus == plugin_has_focus_)
+ return;
+ plugin_has_focus_ = has_focus;
ScopedActiveDelegate active_delegate(this);
@@ -824,7 +837,7 @@ bool WebPluginDelegateImpl::PlatformSetPluginHasFocus(bool focused) {
#ifndef NP_NO_CARBON
case NPEventModelCarbon: {
NPEvent focus_event = { 0 };
- if (focused)
+ if (plugin_has_focus_)
focus_event.what = NPEventType_GetFocusEvent;
else
focus_event.what = NPEventType_LoseFocusEvent;
@@ -837,12 +850,16 @@ bool WebPluginDelegateImpl::PlatformSetPluginHasFocus(bool focused) {
NPCocoaEvent focus_event;
memset(&focus_event, 0, sizeof(focus_event));
focus_event.type = NPCocoaEventFocusChanged;
- focus_event.data.focus.hasFocus = focused;
+ focus_event.data.focus.hasFocus = plugin_has_focus_;
instance()->NPP_HandleEvent(&focus_event);
break;
}
}
- return true;
+}
+
+void WebPluginDelegateImpl::SetContentAreaHasFocus(bool has_focus) {
+ containing_view_has_focus_ = has_focus;
+ SetPluginHasFocus(containing_view_has_focus_ && has_webkit_focus_);
}
void WebPluginDelegateImpl::SetContainerVisibility(bool is_visible) {
@@ -876,8 +893,8 @@ void WebPluginDelegateImpl::SetContainerVisibility(bool is_visible) {
instance()->webplugin()->InvalidateRect(gfx::Rect());
}
-void WebPluginDelegateImpl::WindowFrameChanged(const gfx::Rect& window_frame,
- const gfx::Rect& view_frame) {
+void WebPluginDelegateImpl::WindowFrameChanged(gfx::Rect window_frame,
+ gfx::Rect view_frame) {
instance()->set_window_frame(window_frame);
SetContentAreaOrigin(gfx::Point(view_frame.x(), view_frame.y()));
}
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_win.cc b/webkit/glue/plugins/webplugin_delegate_impl_win.cc
index ee3f083..7a2e314 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_win.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl_win.cc
@@ -265,10 +265,7 @@ WebPluginDelegateImpl::WebPluginDelegateImpl(
user_gesture_msg_factory_(this),
handle_event_depth_(0),
mouse_hook_(NULL),
- first_set_window_call_(true),
- plugin_has_focus_(false),
- has_webkit_focus_(false),
- containing_view_has_focus_(false) {
+ first_set_window_call_(true) {
memset(&window_, 0, sizeof(window_));
const WebPluginInfo& plugin_info = instance_->plugin_lib()->plugin_info();
@@ -1054,7 +1051,7 @@ void WebPluginDelegateImpl::WindowlessSetWindow() {
DCHECK(err == NPERR_NO_ERROR);
}
-bool WebPluginDelegateImpl::PlatformSetPluginHasFocus(bool focused) {
+void WebPluginDelegateImpl::SetFocus(bool focused) {
DCHECK(instance()->windowless());
NPEvent focus_event;
@@ -1063,7 +1060,6 @@ bool WebPluginDelegateImpl::PlatformSetPluginHasFocus(bool focused) {
focus_event.lParam = 0;
instance()->NPP_HandleEvent(&focus_event);
- return true;
}
static bool NPEventFromWebMouseEvent(const WebMouseEvent& event,