Bug 1147521 - Cannot type into comment area of plugin crash UI. r=smaug

This commit is contained in:
Steven Michaud 2015-03-26 19:38:13 -05:00
parent a9fc9c0e52
commit 4723eb4461
3 changed files with 60 additions and 2 deletions

View File

@ -91,6 +91,13 @@
#endif
#endif // XP_WIN
#ifdef XP_MACOSX
// HandlePluginCrashed() and HandlePluginInstantiated() needed from here to
// fix bug 1147521. Should later be replaced by proper interface methods,
// maybe on nsIObjectLoadingContext.
#include "mozilla/dom/HTMLObjectElement.h"
#endif
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
static const char *kPrefJavaMIME = "plugin.java.mime";
@ -867,6 +874,10 @@ nsObjectLoadingContent::InstantiatePluginInstance(bool aIsLoading)
NS_LITERAL_STRING("PluginInstantiated"));
NS_DispatchToCurrentThread(ev);
#ifdef XP_MACOSX
HTMLObjectElement::HandlePluginInstantiated(thisContent->AsElement());
#endif
return NS_OK;
}
@ -2723,14 +2734,19 @@ nsObjectLoadingContent::PluginCrashed(nsIPluginTag* aPluginTag,
LOG(("OBJLC [%p]: Plugin Crashed, queuing crash event", this));
NS_ASSERTION(mType == eType_Plugin, "PluginCrashed at non-plugin type");
nsCOMPtr<nsIContent> thisContent =
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
#ifdef XP_MACOSX
HTMLObjectElement::HandlePluginCrashed(thisContent->AsElement());
#endif
PluginDestroyed();
// Switch to fallback/crashed state, notify
LoadFallback(eFallbackCrashed, true);
// send nsPluginCrashedEvent
nsCOMPtr<nsIContent> thisContent =
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
// Note that aPluginTag in invalidated after we're called, so copy
// out any data we need now.

View File

@ -23,6 +23,7 @@
#ifdef XP_MACOSX
#include "mozilla/EventDispatcher.h"
#include "mozilla/dom/Event.h"
#include "nsFocusManager.h"
#endif
namespace mozilla {
@ -151,6 +152,22 @@ private:
void
HTMLObjectElement::OnFocusBlurPlugin(Element* aElement, bool aFocus)
{
// In general we don't want to call nsIWidget::SetPluginFocused() for any
// Element that doesn't have a plugin running. But if SetPluginFocused(true)
// was just called for aElement while it had a plugin running, we want to
// make sure nsIWidget::SetPluginFocused(false) gets called for it now, even
// if aFocus is true.
if (aFocus) {
nsCOMPtr<nsIObjectLoadingContent> olc = do_QueryInterface(aElement);
bool hasRunningPlugin = false;
if (olc) {
olc->GetHasRunningPlugin(&hasRunningPlugin);
}
if (!hasRunningPlugin) {
aFocus = false;
}
}
if (aFocus || aElement == sLastFocused) {
if (!aFocus) {
sLastFocused = nullptr;
@ -163,6 +180,29 @@ HTMLObjectElement::OnFocusBlurPlugin(Element* aElement, bool aFocus)
}
}
void
HTMLObjectElement::HandlePluginCrashed(Element* aElement)
{
OnFocusBlurPlugin(aElement, false);
}
void
HTMLObjectElement::HandlePluginInstantiated(Element* aElement)
{
// If aElement is already focused when a plugin is instantiated, we need
// to initiate a call to nsIWidget::SetPluginFocused(true). Otherwise
// keyboard input won't work in a click-to-play plugin until aElement
// loses focus and regains it.
nsIContent* focusedContent = nullptr;
nsFocusManager *fm = nsFocusManager::GetFocusManager();
if (fm) {
focusedContent = fm->GetFocusedContent();
}
if (SameCOMIdentity(focusedContent, aElement)) {
OnFocusBlurPlugin(aElement, true);
}
}
void
HTMLObjectElement::HandleFocusBlurPlugin(Element* aElement,
WidgetEvent* aEvent)

View File

@ -36,6 +36,8 @@ public:
// Helper methods
static void OnFocusBlurPlugin(Element* aElement, bool aFocus);
static void HandleFocusBlurPlugin(Element* aElement, WidgetEvent* aEvent);
static void HandlePluginCrashed(Element* aElement);
static void HandlePluginInstantiated(Element* aElement);
// Weak pointer. Null if last action was blur.
static Element* sLastFocused;
#endif