summaryrefslogtreecommitdiffstats
path: root/o3d
diff options
context:
space:
mode:
authorgeer@google.com <geer@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-16 09:19:01 +0000
committergeer@google.com <geer@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-16 09:19:01 +0000
commit2b82c0d249fe3753e198567e505db9baade30136 (patch)
tree6583e5bacfe498b3ec0d3c14180d7ac7bc2291b6 /o3d
parentc75f4d474ccc255b8a3ef4a4da9c37b01e92a5a0 (diff)
downloadchromium_src-2b82c0d249fe3753e198567e505db9baade30136.zip
chromium_src-2b82c0d249fe3753e198567e505db9baade30136.tar.gz
chromium_src-2b82c0d249fe3753e198567e505db9baade30136.tar.bz2
Prevents changing the stored tab handle at switching tabs. This fixes a bug where O3D would keep rendering on another tab in Safari on OSX 10.5.8. When the area had been clicked before switching tabs, a lost focus event just before switching would reset the stored handle to the new, non-O3D tab.
Also fixes the tab detection after the o3d page has been dragged to another window. Review URL: http://codereview.chromium.org/3317018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59628 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r--o3d/plugin/cross/o3d_glue.cc10
-rw-r--r--o3d/plugin/cross/o3d_glue.h2
-rw-r--r--o3d/plugin/mac/main_mac.mm6
3 files changed, 10 insertions, 8 deletions
diff --git a/o3d/plugin/cross/o3d_glue.cc b/o3d/plugin/cross/o3d_glue.cc
index 2f8bcbd..84035f6 100644
--- a/o3d/plugin/cross/o3d_glue.cc
+++ b/o3d/plugin/cross/o3d_glue.cc
@@ -296,18 +296,18 @@ void PluginObject::DeleteRenderer() {
// It records the time of the event and tries to read the selected tab value
// from Safari (on other browsers this tab value should always be NULL).
// Written so that last_mac_event_time_ is always valid or NULL.
-void PluginObject::MacEventReceived() {
+void PluginObject::MacEventReceived(bool updateTab) {
CFDateRef now = CFDateCreate(NULL, CFAbsoluteTimeGetCurrent());
CFDateRef previousTime = last_mac_event_time_;
last_mac_event_time_ = now;
if (previousTime != NULL) {
CFRelease(previousTime);
}
- if (!mac_cocoa_window_) {
- mac_cocoa_window_ = o3d::SafariBrowserWindowForWindowRef(mac_window_);
+ mac_cocoa_window_ = o3d::SafariBrowserWindowForWindowRef(mac_window_);
+ if (!mac_window_selected_tab_ || updateTab) {
+ mac_window_selected_tab_ =
+ o3d::SelectedTabForSafariBrowserWindow(mac_cocoa_window_);
}
- mac_window_selected_tab_ =
- o3d::SelectedTabForSafariBrowserWindow(mac_cocoa_window_);
}
// Returns the time elapsed since the MacEventReceived function was last called.
diff --git a/o3d/plugin/cross/o3d_glue.h b/o3d/plugin/cross/o3d_glue.h
index 97c88af..9af13dd 100644
--- a/o3d/plugin/cross/o3d_glue.h
+++ b/o3d/plugin/cross/o3d_glue.h
@@ -466,7 +466,7 @@ class PluginObject: public NPObject {
#ifdef OS_MACOSX
// Methods needed for the Safari tab-switching hack.
- void MacEventReceived();
+ void MacEventReceived(bool updateTab);
CFTimeInterval TimeSinceLastMacEvent();
diff --git a/o3d/plugin/mac/main_mac.mm b/o3d/plugin/mac/main_mac.mm
index f3ed8c7..5d28f236 100644
--- a/o3d/plugin/mac/main_mac.mm
+++ b/o3d/plugin/mac/main_mac.mm
@@ -737,7 +737,7 @@ bool HandleMacEvent(EventRecord* the_event, NPP instance) {
// Help the plugin keep track of when we last saw an event so the CFTimer can
// notice if we get cut off, eg by our tab being hidden by Safari, which there
// is no other way for us to detect.
- obj->MacEventReceived();
+ obj->MacEventReceived(the_event->what != nsPluginEventType_LoseFocusEvent);
switch (the_event->what) {
case nullEvent:
@@ -831,7 +831,9 @@ bool HandleCocoaEvent(NPP instance, NPCocoaEvent* the_event,
if (g_logger) g_logger->UpdateLogging();
- obj->MacEventReceived();
+ bool lostFocus = the_event->type == NPCocoaEventFocusChanged &&
+ !the_event->data.focus.hasFocus;
+ obj->MacEventReceived(!lostFocus);
switch (the_event->type) {
case NPCocoaEventDrawRect:
// We need to call the render callback from here if we are rendering